diff --git a/bt5/erp5_calendar/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_catalog_stock_list.xml b/bt5/erp5_calendar/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_catalog_stock_list.xml index 139528ffd4fcc3cb395a1cc37c34b45eb7d6b4c3..d82324b567c674df8e850fb1675838f178d191d2 100644 --- a/bt5/erp5_calendar/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_catalog_stock_list.xml +++ b/bt5/erp5_calendar/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_catalog_stock_list.xml @@ -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 diff --git a/product/ERP5/Document/PresencePeriod.py b/product/ERP5/Document/PresencePeriod.py index da6c4b2fb37edc8b6c0cb6d7da5203c8f52aef0c..5edfa1937e501afdce9daf33a30e421dace7d615 100644 --- a/product/ERP5/Document/PresencePeriod.py +++ b/product/ERP5/Document/PresencePeriod.py @@ -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):