Commit 136a760e authored by Gabriel Monnerat's avatar Gabriel Monnerat

Move changes on asMovementList method from PresencePeriod to...

Move changes on asMovementList method from PresencePeriod to GroupCalendarAssignment to keep Leave Period working as Expected.
parent da089563
...@@ -34,5 +34,30 @@ class GroupCalendarAssignment(PresencePeriod): ...@@ -34,5 +34,30 @@ class GroupCalendarAssignment(PresencePeriod):
meta_type = 'ERP5 Group Calendar Assignment' meta_type = 'ERP5 Group Calendar Assignment'
portal_type = 'Group Calendar Assignment' portal_type = 'Group Calendar Assignment'
# Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
\ No newline at end of file
security.declareProtected( Permissions.AccessContentsInformation,
'asMovementList')
def asMovementList(self):
"""
Generate multiple movement from a single one.
It is used for cataloging a movement multiple time in
the movement/stock tables.
Ex: a movement have multiple destinations.
asMovementList returns a list a movement context with different
single destination.
"""
result = []
if self.getDestinationUid() is None:
return result
group_calendar = self.getParentValue()
presence_period_list = group_calendar.objectValues(portal_type="Group Presence Period")
for presence_period in presence_period_list:
for from_date, to_date in presence_period._getDatePeriodList():
if from_date.greaterThanEqualTo(self.getStartDate()) and \
to_date.lessThanEqualTo(self.getStopDate() or group_calendar.getStopDate()):
result.append(self.asContext(self, start_date=to_date, stop_date=from_date))
return result
374 375
\ No newline at end of file \ No newline at end of file
...@@ -102,15 +102,9 @@ class PresencePeriod(Movement, PeriodicityMixin): ...@@ -102,15 +102,9 @@ class PresencePeriod(Movement, PeriodicityMixin):
single destination. single destination.
""" """
result = [] result = []
if self.getDestinationUid() is None: for from_date, to_date in self._getDatePeriodList():
return result result.append(self.asContext(self, start_date=to_date,
group_calendar = self.getParentValue() stop_date=from_date))
presence_period_list = group_calendar.objectValues(portal_type="Group Presence Period")
for presence_period in presence_period_list:
for from_date, to_date in presence_period._getDatePeriodList():
if from_date.greaterThanEqualTo(self.getStartDate()) and to_date.lessThanEqualTo(self.getStopDate() or group_calendar.getStopDate()):
result.append(self.asContext(self, start_date=to_date, stop_date=from_date))
return result return result
def _getDatePeriodList(self): def _getDatePeriodList(self):
......
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