Commit 5b9481ed authored by Jérome Perrin's avatar Jérome Perrin

base: fix Person_getAvailableAssignmentValueList for assignments with only start date

Because stop date gets the start date by acquisition when no stop date is set,
scripts need to take special care that the date is actually set. This was not
the case in this script, so assignments with only a start date but no stop date
where not considered.

This was especially visible in Base_getDialogSectionCategoryItemList which is
used to select the group in user preferences and in reports dialogs
parent d2f0e9a9
......@@ -3,7 +3,7 @@ assignment_list = []
for assignment in context.contentValues(portal_type='Assignment', checked_permission="Access contents information"):
if assignment.getValidationState() == 'open':
start_date = assignment.getStartDate()
stop_date = assignment.getStopDate()
stop_date = assignment.getStopDate() if assignment.hasStopDate() else None
if start_date is not None and stop_date is not None and start_date <= current_date < stop_date:
assignment_list.append(assignment)
elif start_date is not None and stop_date is None and start_date <= current_date:
......
......@@ -1878,6 +1878,16 @@ class Base_getDialogSectionCategoryItemListTest(ERP5TypeTestCase):
['Main Group/Sub Group', 'group/main_group/sub_group'],
])
def test_assignments_with_start_date_only_are_considered(self):
self.person.newContent(portal_type='Assignment', group='main_group/sub_group', start_date=DateTime(1970, 1, 1)).open()
self.tic()
self.login(self.user_id)
self.assertEqual(
self.portal.Base_getDialogSectionCategoryItemList(), [
['', ''],
['Main Group/Sub Group', 'group/main_group/sub_group'],
])
def test_non_person_user(self):
self.assertEqual(
self.portal.Base_getDialogSectionCategoryItemList(), [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment