diff --git a/product/ERP5/Document/BusinessProcess.py b/product/ERP5/Document/BusinessProcess.py index ae13fe14a657e79e80da9d39fb52e93586156faf..7467247737a435ab3fc15be43ee7f52dd8e6a6b8 100644 --- a/product/ERP5/Document/BusinessProcess.py +++ b/product/ERP5/Document/BusinessProcess.py @@ -701,17 +701,9 @@ class BusinessProcess(Path, XMLObject): movement._edit(**kw) business_link = self.getBusinessLinkValueList(trade_phase=trade_phase, context=movement) - # we have to exclude trade model path and business link in causality list - # because original amount might come from another generatedAmountList - # calculation - causality_list = [trade_model_path.getRelativeUrl()] \ - + [x.getRelativeUrl() for x in business_link] - excluded_portal_type_set = set(self.getPortalTradeModelPathTypeList() - + self.getPortalBusinessLinkTypeList()) - for causality_value in movement.getCausalityValueList(): - if not(causality_value.getPortalType() in excluded_portal_type_set): - causality_list.append(causality_value.getRelativeUrl()) - movement._setCausalityList(causality_list) + movement._setCausalityList([trade_model_path.getRelativeUrl()] + + [x.getRelativeUrl() for x in business_link] + + movement.getCausalityList()) result.append(movement) if not explanation.getSpecialiseValue().getSameTotalQuantity(): diff --git a/product/ERP5/Document/QuantitySplitSolver.py b/product/ERP5/Document/QuantitySplitSolver.py index 3137a8f1ffce6865515a4fa4a1c3913fa467a909..22b5893a26364e3a66ddfe753081fb1e9f4bfda6 100644 --- a/product/ERP5/Document/QuantitySplitSolver.py +++ b/product/ERP5/Document/QuantitySplitSolver.py @@ -34,7 +34,7 @@ from Products.ERP5Type import Permissions, PropertySheet, interfaces from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5.mixin.solver import SolverMixin from Products.ERP5.mixin.configurable import ConfigurableMixin -from Products.ERP5.MovementCollectionDiff import _getPropertyDict +from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject): """Target solver that split the prevision based on quantity. @@ -91,9 +91,7 @@ class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject): split_index += 1 new_id = "%s_split_%s" % (simulation_movement.getId(), split_index) # Copy at same level - rule = applied_rule.getSpecialiseValue() - kw = _getPropertyDict(simulation_movement, - updating_tester_list=rule._getUpdatingTesterList()) + kw = _getPropertyAndCategoryList(simulation_movement) kw.update({'portal_type':simulation_movement.getPortalType(), 'id':new_id, 'delivery':None, diff --git a/product/ERP5/MovementCollectionDiff.py b/product/ERP5/MovementCollectionDiff.py index d44bb7481645b64b2cb06db0427dc88619d4c549..2448f2bf16f9f5d67789adcbbfe29fe850236cda 100644 --- a/product/ERP5/MovementCollectionDiff.py +++ b/product/ERP5/MovementCollectionDiff.py @@ -41,12 +41,11 @@ class MovementCollectionDiff(object): # Declarative interfaces zope.interface.implements(interfaces.IMovementCollectionDiff,) - def __init__(self, updating_tester_list=None): + def __init__(self): self._deletable_movement_list = [] self._new_movement_list = [] self._updatable_movement_list = [] self._property_dict_dict = {} - self._updating_tester_list = updating_tester_list def getDeletableMovementList(self): """ @@ -91,13 +90,11 @@ class MovementCollectionDiff(object): property_dict = self._property_dict_dict.get(movement) # for new movement, property_dict should be calculated here. if property_dict is None: - if self._updating_tester_list is not None: - property_dict = _getPropertyDict(movement, - updating_tester_list=self._updating_tester_list) - else: - property_dict = _getPropertyList(movement) - property_dict.update(_getCategoryList(movement, acquire=False)) - return property_dict + property_dict = _getPropertyList(movement) + property_dict.update(_getCategoryList(movement, acquire=False)) + return property_dict + else: + return property_dict def addUpdatableMovement(self, movement, property_dict): """ @@ -118,17 +115,6 @@ def _getPropertyAndCategoryList(document): property_dict.update(_getCategoryList(document)) return property_dict -def _getPropertyDict(document, updating_tester_list=None): - assert updating_tester_list is not None - property_dict = {} - for tester in updating_tester_list: - property_dict.update(tester.getExpandablePropertyDict(document)) - # causality and trade phase are controled by business process, not rules, - # so they are not availables as part of updating tester list - for property_id in ("causality", "trade_phase"): - property_dict.update(**{property_id: document.getPropertyList(property_id)}) - return property_dict - def _getPropertyList(document, acquire=True): property_map = document.getPropertyMap() bad_property_list = ['id', 'uid', 'categories_list', 'last_id',] diff --git a/product/ERP5/interfaces/equivalence_tester.py b/product/ERP5/interfaces/equivalence_tester.py index 1bbcaa0fad4b73620d318ac84778b5ce2044defc..9fc5edcc977050da93ea5f71fbbcaa0493283d88 100644 --- a/product/ERP5/interfaces/equivalence_tester.py +++ b/product/ERP5/interfaces/equivalence_tester.py @@ -124,14 +124,6 @@ class IEquivalenceTester(Interface): decision_movement -- a delivery movement (decision) """ - def getExpandablePropertyDict(input_movement): - """ - Returns a list of properties coming from input movement to - update on simulation movement - - input_movement -- a prevision movement - """ - def update(prevision_movement, decision_movement): """ Updates decision_movement with properties from diff --git a/product/ERP5/interfaces/movement_collection_updater.py b/product/ERP5/interfaces/movement_collection_updater.py index 3cc376d7e22cb853b16ca563722bcf0f30bc038d..22204d16dcb7bc310dd8477046213a724c6de867 100644 --- a/product/ERP5/interfaces/movement_collection_updater.py +++ b/product/ERP5/interfaces/movement_collection_updater.py @@ -40,8 +40,7 @@ class IMovementCollectionUpdater(Interface): obtained from an IMovementCollection, thus generating an IMovementCollectionDiff. """ - def getMovementCollectionDiff(context, rounding=False, movement_generator=None, - updating_tester_list=None): + def getMovementCollectionDiff(context, rounding=False, movement_generator=None): """ Return a IMovementCollectionDiff by comparing movements the list of movements of context and the list of movements @@ -53,15 +52,9 @@ class IMovementCollectionUpdater(Interface): movement_generator -- an optional IMovementGenerator (if not specified, a context implicit IMovementGenerator will be used) - - updating_tester_list -- an optional list of testers used to get properties - that we care on movements. This allows to improve - performance by not looking at properties - we don't care """ - def updateMovementCollection(context, rounding=False, movement_generator=None, - updating_tester_list=None): + def updateMovementCollection(context, rounding=False, movement_generator=None): """ Invoke getMovementCollectionDiff and update context with the resulting IMovementCollectionDiff. @@ -72,9 +65,4 @@ class IMovementCollectionUpdater(Interface): movement_generator -- an optional IMovementGenerator (if not specified, a context implicit IMovementGenerator will be used) - - updating_tester_list -- an optional list of testers used to get properties - that we care on movements. This allows to improve - performance by not looking at properties - we don't care """ diff --git a/product/ERP5/mixin/equivalence_tester.py b/product/ERP5/mixin/equivalence_tester.py index 45d53d6fbb37386e59f90bc67a4aa2246fe4a192..6ef0c3c69128f46881f8a6eeeeb8d7fed06660ef 100644 --- a/product/ERP5/mixin/equivalence_tester.py +++ b/product/ERP5/mixin/equivalence_tester.py @@ -212,10 +212,3 @@ class EquivalenceTesterMixin: tested_property = self.getTestedProperty() return {tested_property: self._getTestedPropertyValue(prevision_movement, tested_property)} - - def getExpandablePropertyDict(self, input_movement): - """ - By default, the result of getUpdatableMovement is doing exactly what - we need - """ - return self.getUpdatablePropertyDict(input_movement, None) \ No newline at end of file diff --git a/product/ERP5/mixin/movement_collection_updater.py b/product/ERP5/mixin/movement_collection_updater.py index 27a9f594655ec742b96f969ac0c681b1d9d90265..e723f5ff6037b5dd5656efd6a1352c0a07abcd00 100644 --- a/product/ERP5/mixin/movement_collection_updater.py +++ b/product/ERP5/mixin/movement_collection_updater.py @@ -51,8 +51,7 @@ class MovementCollectionUpdaterMixin: # Implementation of IMovementCollectionUpdater def getMovementCollectionDiff(self, context, rounding=False, - movement_generator=None, - updating_tester_list=None): + movement_generator=None): """ Return a IMovementCollectionDiff by comparing movements the list of movements of context and the list of movements @@ -64,8 +63,6 @@ class MovementCollectionUpdaterMixin: movement_generator -- an optional IMovementGenerator (if not specified, a context implicit IMovementGenerator will be used) - - updating_tester_list -- a list of testers used to build updatable dicts """ # We suppose here that we have an IMovementCollection in hand decision_movement_list = context.getMovementList() @@ -141,8 +138,7 @@ class MovementCollectionUpdaterMixin: prevision_to_decision_map.append((prevision_movement, map_list)) # Third, time to create the diff - movement_collection_diff = MovementCollectionDiff( - updating_tester_list=updating_tester_list) + movement_collection_diff = MovementCollectionDiff() for (prevision_movement, decision_movement_list) in prevision_to_decision_map: self._extendMovementCollectionDiff(movement_collection_diff, prevision_movement, decision_movement_list) @@ -150,8 +146,7 @@ class MovementCollectionUpdaterMixin: return movement_collection_diff def updateMovementCollection(self, context, rounding=False, - movement_generator=None, - updating_tester_list=None): + movement_generator=None): """ Invoke getMovementCollectionDiff and update context with the resulting IMovementCollectionDiff. @@ -162,12 +157,9 @@ class MovementCollectionUpdaterMixin: movement_generator -- an optional IMovementGenerator (if not specified, a context implicit IMovementGenerator will be used) - - updating_tester_list -- a list of testers used to build updatable dicts """ movement_diff = self.getMovementCollectionDiff(context, - rounding=rounding, movement_generator=movement_generator, - updating_tester_list=updating_tester_list) + rounding=rounding, movement_generator=movement_generator) # Apply Diff for movement in movement_diff.getDeletableMovementList(): diff --git a/product/ERP5/mixin/rule.py b/product/ERP5/mixin/rule.py index 24721f07f164b29cc33f9c54f1a04f067750c4bc..c56de5aa641004d899489c40ce225a778da9cba7 100644 --- a/product/ERP5/mixin/rule.py +++ b/product/ERP5/mixin/rule.py @@ -31,7 +31,6 @@ from AccessControl import ClassSecurityInfo from Acquisition import aq_base from Products.CMFCore.utils import getToolByName from Products.ERP5Type import Permissions, interfaces -from Products.ERP5Type.Cache import caching_instance_method from Products.ERP5Type.Core.Predicate import Predicate from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList @@ -206,9 +205,7 @@ class RuleMixin(Predicate): # Update movements # NOTE-JPS: it is OK to make rounding a standard parameter of rules # although rounding in simulation is not recommended at all - self.updateMovementCollection(applied_rule, - movement_generator=self._getMovementGenerator(applied_rule), - updating_tester_list=self._getUpdatingTesterList()) + self.updateMovementCollection(applied_rule, movement_generator=self._getMovementGenerator(applied_rule)) # And forward expand for movement in applied_rule.getMovementList(): movement.expand(**kw)