Commit 5c6164b0 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

revert changes related to "on movement collections, use list of properties defined in rules".

* more values come outside testers, i.e. rule itself and Business Process procedure.
parent 60dd19f8
...@@ -701,17 +701,9 @@ class BusinessProcess(Path, XMLObject): ...@@ -701,17 +701,9 @@ class BusinessProcess(Path, XMLObject):
movement._edit(**kw) movement._edit(**kw)
business_link = self.getBusinessLinkValueList(trade_phase=trade_phase, business_link = self.getBusinessLinkValueList(trade_phase=trade_phase,
context=movement) context=movement)
# we have to exclude trade model path and business link in causality list movement._setCausalityList([trade_model_path.getRelativeUrl()]
# because original amount might come from another generatedAmountList + [x.getRelativeUrl() for x in business_link]
# calculation + movement.getCausalityList())
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)
result.append(movement) result.append(movement)
if not explanation.getSpecialiseValue().getSameTotalQuantity(): if not explanation.getSpecialiseValue().getSameTotalQuantity():
......
...@@ -34,7 +34,7 @@ from Products.ERP5Type import Permissions, PropertySheet, interfaces ...@@ -34,7 +34,7 @@ from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.mixin.solver import SolverMixin from Products.ERP5.mixin.solver import SolverMixin
from Products.ERP5.mixin.configurable import ConfigurableMixin from Products.ERP5.mixin.configurable import ConfigurableMixin
from Products.ERP5.MovementCollectionDiff import _getPropertyDict from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject): class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject):
"""Target solver that split the prevision based on quantity. """Target solver that split the prevision based on quantity.
...@@ -91,9 +91,7 @@ class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject): ...@@ -91,9 +91,7 @@ class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject):
split_index += 1 split_index += 1
new_id = "%s_split_%s" % (simulation_movement.getId(), split_index) new_id = "%s_split_%s" % (simulation_movement.getId(), split_index)
# Copy at same level # Copy at same level
rule = applied_rule.getSpecialiseValue() kw = _getPropertyAndCategoryList(simulation_movement)
kw = _getPropertyDict(simulation_movement,
updating_tester_list=rule._getUpdatingTesterList())
kw.update({'portal_type':simulation_movement.getPortalType(), kw.update({'portal_type':simulation_movement.getPortalType(),
'id':new_id, 'id':new_id,
'delivery':None, 'delivery':None,
......
...@@ -41,12 +41,11 @@ class MovementCollectionDiff(object): ...@@ -41,12 +41,11 @@ class MovementCollectionDiff(object):
# Declarative interfaces # Declarative interfaces
zope.interface.implements(interfaces.IMovementCollectionDiff,) zope.interface.implements(interfaces.IMovementCollectionDiff,)
def __init__(self, updating_tester_list=None): def __init__(self):
self._deletable_movement_list = [] self._deletable_movement_list = []
self._new_movement_list = [] self._new_movement_list = []
self._updatable_movement_list = [] self._updatable_movement_list = []
self._property_dict_dict = {} self._property_dict_dict = {}
self._updating_tester_list = updating_tester_list
def getDeletableMovementList(self): def getDeletableMovementList(self):
""" """
...@@ -91,13 +90,11 @@ class MovementCollectionDiff(object): ...@@ -91,13 +90,11 @@ class MovementCollectionDiff(object):
property_dict = self._property_dict_dict.get(movement) property_dict = self._property_dict_dict.get(movement)
# for new movement, property_dict should be calculated here. # for new movement, property_dict should be calculated here.
if property_dict is None: if property_dict is None:
if self._updating_tester_list is not None: property_dict = _getPropertyList(movement)
property_dict = _getPropertyDict(movement, property_dict.update(_getCategoryList(movement, acquire=False))
updating_tester_list=self._updating_tester_list) return property_dict
else: else:
property_dict = _getPropertyList(movement) return property_dict
property_dict.update(_getCategoryList(movement, acquire=False))
return property_dict
def addUpdatableMovement(self, movement, property_dict): def addUpdatableMovement(self, movement, property_dict):
""" """
...@@ -118,17 +115,6 @@ def _getPropertyAndCategoryList(document): ...@@ -118,17 +115,6 @@ def _getPropertyAndCategoryList(document):
property_dict.update(_getCategoryList(document)) property_dict.update(_getCategoryList(document))
return property_dict 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): def _getPropertyList(document, acquire=True):
property_map = document.getPropertyMap() property_map = document.getPropertyMap()
bad_property_list = ['id', 'uid', 'categories_list', 'last_id',] bad_property_list = ['id', 'uid', 'categories_list', 'last_id',]
......
...@@ -124,14 +124,6 @@ class IEquivalenceTester(Interface): ...@@ -124,14 +124,6 @@ class IEquivalenceTester(Interface):
decision_movement -- a delivery movement (decision) 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): def update(prevision_movement, decision_movement):
""" """
Updates decision_movement with properties from Updates decision_movement with properties from
......
...@@ -40,8 +40,7 @@ class IMovementCollectionUpdater(Interface): ...@@ -40,8 +40,7 @@ class IMovementCollectionUpdater(Interface):
obtained from an IMovementCollection, thus generating obtained from an IMovementCollection, thus generating
an IMovementCollectionDiff. an IMovementCollectionDiff.
""" """
def getMovementCollectionDiff(context, rounding=False, movement_generator=None, def getMovementCollectionDiff(context, rounding=False, movement_generator=None):
updating_tester_list=None):
""" """
Return a IMovementCollectionDiff by comparing movements Return a IMovementCollectionDiff by comparing movements
the list of movements of context and the list of movements the list of movements of context and the list of movements
...@@ -53,15 +52,9 @@ class IMovementCollectionUpdater(Interface): ...@@ -53,15 +52,9 @@ class IMovementCollectionUpdater(Interface):
movement_generator -- an optional IMovementGenerator movement_generator -- an optional IMovementGenerator
(if not specified, a context implicit (if not specified, a context implicit
IMovementGenerator will be used) 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, def updateMovementCollection(context, rounding=False, movement_generator=None):
updating_tester_list=None):
""" """
Invoke getMovementCollectionDiff and update context with Invoke getMovementCollectionDiff and update context with
the resulting IMovementCollectionDiff. the resulting IMovementCollectionDiff.
...@@ -72,9 +65,4 @@ class IMovementCollectionUpdater(Interface): ...@@ -72,9 +65,4 @@ class IMovementCollectionUpdater(Interface):
movement_generator -- an optional IMovementGenerator movement_generator -- an optional IMovementGenerator
(if not specified, a context implicit (if not specified, a context implicit
IMovementGenerator will be used) 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
""" """
...@@ -212,10 +212,3 @@ class EquivalenceTesterMixin: ...@@ -212,10 +212,3 @@ class EquivalenceTesterMixin:
tested_property = self.getTestedProperty() tested_property = self.getTestedProperty()
return {tested_property: self._getTestedPropertyValue(prevision_movement, return {tested_property: self._getTestedPropertyValue(prevision_movement,
tested_property)} 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
...@@ -51,8 +51,7 @@ class MovementCollectionUpdaterMixin: ...@@ -51,8 +51,7 @@ class MovementCollectionUpdaterMixin:
# Implementation of IMovementCollectionUpdater # Implementation of IMovementCollectionUpdater
def getMovementCollectionDiff(self, context, rounding=False, def getMovementCollectionDiff(self, context, rounding=False,
movement_generator=None, movement_generator=None):
updating_tester_list=None):
""" """
Return a IMovementCollectionDiff by comparing movements Return a IMovementCollectionDiff by comparing movements
the list of movements of context and the list of movements the list of movements of context and the list of movements
...@@ -64,8 +63,6 @@ class MovementCollectionUpdaterMixin: ...@@ -64,8 +63,6 @@ class MovementCollectionUpdaterMixin:
movement_generator -- an optional IMovementGenerator movement_generator -- an optional IMovementGenerator
(if not specified, a context implicit (if not specified, a context implicit
IMovementGenerator will be used) 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 # We suppose here that we have an IMovementCollection in hand
decision_movement_list = context.getMovementList() decision_movement_list = context.getMovementList()
...@@ -141,8 +138,7 @@ class MovementCollectionUpdaterMixin: ...@@ -141,8 +138,7 @@ class MovementCollectionUpdaterMixin:
prevision_to_decision_map.append((prevision_movement, map_list)) prevision_to_decision_map.append((prevision_movement, map_list))
# Third, time to create the diff # Third, time to create the diff
movement_collection_diff = MovementCollectionDiff( movement_collection_diff = MovementCollectionDiff()
updating_tester_list=updating_tester_list)
for (prevision_movement, decision_movement_list) in prevision_to_decision_map: for (prevision_movement, decision_movement_list) in prevision_to_decision_map:
self._extendMovementCollectionDiff(movement_collection_diff, prevision_movement, self._extendMovementCollectionDiff(movement_collection_diff, prevision_movement,
decision_movement_list) decision_movement_list)
...@@ -150,8 +146,7 @@ class MovementCollectionUpdaterMixin: ...@@ -150,8 +146,7 @@ class MovementCollectionUpdaterMixin:
return movement_collection_diff return movement_collection_diff
def updateMovementCollection(self, context, rounding=False, def updateMovementCollection(self, context, rounding=False,
movement_generator=None, movement_generator=None):
updating_tester_list=None):
""" """
Invoke getMovementCollectionDiff and update context with Invoke getMovementCollectionDiff and update context with
the resulting IMovementCollectionDiff. the resulting IMovementCollectionDiff.
...@@ -162,12 +157,9 @@ class MovementCollectionUpdaterMixin: ...@@ -162,12 +157,9 @@ class MovementCollectionUpdaterMixin:
movement_generator -- an optional IMovementGenerator movement_generator -- an optional IMovementGenerator
(if not specified, a context implicit (if not specified, a context implicit
IMovementGenerator will be used) IMovementGenerator will be used)
updating_tester_list -- a list of testers used to build updatable dicts
""" """
movement_diff = self.getMovementCollectionDiff(context, movement_diff = self.getMovementCollectionDiff(context,
rounding=rounding, movement_generator=movement_generator, rounding=rounding, movement_generator=movement_generator)
updating_tester_list=updating_tester_list)
# Apply Diff # Apply Diff
for movement in movement_diff.getDeletableMovementList(): for movement in movement_diff.getDeletableMovementList():
......
...@@ -31,7 +31,6 @@ from AccessControl import ClassSecurityInfo ...@@ -31,7 +31,6 @@ from AccessControl import ClassSecurityInfo
from Acquisition import aq_base from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5Type import Permissions, interfaces from Products.ERP5Type import Permissions, interfaces
from Products.ERP5Type.Cache import caching_instance_method
from Products.ERP5Type.Core.Predicate import Predicate from Products.ERP5Type.Core.Predicate import Predicate
from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
...@@ -206,9 +205,7 @@ class RuleMixin(Predicate): ...@@ -206,9 +205,7 @@ class RuleMixin(Predicate):
# Update movements # Update movements
# NOTE-JPS: it is OK to make rounding a standard parameter of rules # NOTE-JPS: it is OK to make rounding a standard parameter of rules
# although rounding in simulation is not recommended at all # although rounding in simulation is not recommended at all
self.updateMovementCollection(applied_rule, self.updateMovementCollection(applied_rule, movement_generator=self._getMovementGenerator(applied_rule))
movement_generator=self._getMovementGenerator(applied_rule),
updating_tester_list=self._getUpdatingTesterList())
# And forward expand # And forward expand
for movement in applied_rule.getMovementList(): for movement in applied_rule.getMovementList():
movement.expand(**kw) movement.expand(**kw)
......
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