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):
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():
......
......@@ -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,
......
......@@ -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',]
......
......@@ -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
......
......@@ -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
"""
......@@ -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
......@@ -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():
......
......@@ -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)
......
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