Commit da089563 authored by Gabriel Monnerat's avatar Gabriel Monnerat

Improve code to generate movements for each Group Presence Period according to the period

parent b0d9277b
......@@ -114,7 +114,7 @@ WHERE\n
getSourceSectionUid[loop_item],\n
getSourceUid[loop_item],\n
getResourceUid[loop_item],\n
getInventoriatedQuantity[loop_item],\n
-(mov_item.getInventoriatedQuantity() or 0),\n
isCancellationAmount[loop_item],\n
isAccountable[loop_item],\n
mov_item.getStopDate(),\n
......
......@@ -71,20 +71,6 @@ class PresencePeriod(Movement, PeriodicityMixin):
"""
return 1
security.declareProtected(Permissions.AccessContentsInformation,
'getDestinationUid')
def getDestinationUid(self, *args, **kw):
"""
Return the destination uid
"""
# XXX Should be configurable via acquisition
destination_value = self.getParentValue().getDestinationValue()
if destination_value is not None:
destination_uid = destination_value.getUid()
else:
destination_uid = self.getParentUid()
return destination_uid
security.declareProtected(Permissions.AccessContentsInformation,
'getInventoriatedQuantity')
def getInventoriatedQuantity(self, default=None, *args, **kw):
......@@ -116,9 +102,15 @@ class PresencePeriod(Movement, PeriodicityMixin):
single destination.
"""
result = []
for from_date, to_date in self._getDatePeriodList():
result.append(self.asContext(self, start_date=to_date,
stop_date=from_date))
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
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