Commit 0281b432 authored by Sebastien Robin's avatar Sebastien Robin

erp5_calendar: customize _getDatePeriodDataList instead of asMovementList

This makes less code to customize in GroupCalendarAssignment
parent 02e7fd16
...@@ -38,26 +38,13 @@ class GroupCalendarAssignment(PresencePeriod): ...@@ -38,26 +38,13 @@ class GroupCalendarAssignment(PresencePeriod):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected( Permissions.AccessContentsInformation, def _getDatePeriodDataList(self):
'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 = [] result = []
group_calendar = self.getSpecialiseValue() group_calendar = self.getSpecialiseValue()
if None in (self.getDestinationUid(), group_calendar): if not(None in (self.getDestinationUid(), group_calendar)):
return result presence_period_list = group_calendar.objectValues(
presence_period_list = group_calendar.objectValues(portal_type="Group Presence Period") portal_type="Group Presence Period")
for presence_period in presence_period_list: for presence_period in presence_period_list:
for date_period_data in presence_period._getDatePeriodDataList(): result.extend(presence_period._getDatePeriodDataList())
if date_period_data['start_date'].greaterThanEqualTo(self.getStartDate()) and \
date_period_data['stop_date'].lessThanEqualTo(self.getStopDate() or group_calendar.getStopDate()):
result.append(self.asContext(self, **date_period_data))
return result return result
382 384
\ No newline at end of file \ No newline at end of file
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