From 0281b43242a161da034d83d4e6fca15d93a0cf29 Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Wed, 9 Apr 2014 17:47:07 +0200 Subject: [PATCH] erp5_calendar: customize _getDatePeriodDataList instead of asMovementList This makes less code to customize in GroupCalendarAssignment --- .../document.erp5.GroupCalendarAssignment.py | 27 +++++-------------- bt5/erp5_calendar/bt/revision | 2 +- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/bt5/erp5_calendar/DocumentTemplateItem/portal_components/document.erp5.GroupCalendarAssignment.py b/bt5/erp5_calendar/DocumentTemplateItem/portal_components/document.erp5.GroupCalendarAssignment.py index 053898b671..238fabd891 100644 --- a/bt5/erp5_calendar/DocumentTemplateItem/portal_components/document.erp5.GroupCalendarAssignment.py +++ b/bt5/erp5_calendar/DocumentTemplateItem/portal_components/document.erp5.GroupCalendarAssignment.py @@ -38,26 +38,13 @@ class GroupCalendarAssignment(PresencePeriod): security = ClassSecurityInfo() security.declareObjectProtected(Permissions.AccessContentsInformation) - 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. - """ + def _getDatePeriodDataList(self): result = [] group_calendar = self.getSpecialiseValue() - if None in (self.getDestinationUid(), group_calendar): - return result - presence_period_list = group_calendar.objectValues(portal_type="Group Presence Period") - for presence_period in presence_period_list: - for date_period_data in 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)) + if not(None in (self.getDestinationUid(), group_calendar)): + presence_period_list = group_calendar.objectValues( + portal_type="Group Presence Period") + for presence_period in presence_period_list: + result.extend(presence_period._getDatePeriodDataList()) return result + diff --git a/bt5/erp5_calendar/bt/revision b/bt5/erp5_calendar/bt/revision index 6d540e9f23..e41567feb8 100644 --- a/bt5/erp5_calendar/bt/revision +++ b/bt5/erp5_calendar/bt/revision @@ -1 +1 @@ -382 \ No newline at end of file +384 \ No newline at end of file -- 2.30.9