Commit aa7b0075 authored by Sebastien Robin's avatar Sebastien Robin

mrp simulation: allow to customize transformation rule to define to reverse...

mrp simulation: allow to customize transformation rule to define to reverse input source/destination
parent b0efaa03
......@@ -63,7 +63,8 @@ class TransformationSimulationRule(RuleMixin, MovementCollectionUpdaterMixin):
"""
Return the movement generator to use in the expand process
"""
return TransformationRuleMovementGenerator(applied_rule=context, rule=self)
return TransformationRuleMovementGenerator(applied_rule=context, rule=self,
produce_at_source=True)
def _isProfitAndLossMovement(self, movement):
# For a kind of trade rule, a profit and loss movement lacks source
......@@ -98,6 +99,11 @@ class TransformationSimulationRule(RuleMixin, MovementCollectionUpdaterMixin):
class TransformationRuleMovementGenerator(MovementGeneratorMixin):
def __init__(self, *args, **kw):
produce_at_source = kw.pop("produce_at_source", False)
super(TransformationRuleMovementGenerator, self).__init__(*args, **kw)
self.produce_at_source = produce_at_source
def _getUpdatePropertyDict(self, input_movement):
return {}
......@@ -106,9 +112,13 @@ class TransformationRuleMovementGenerator(MovementGeneratorMixin):
portal = self._applied_rule.getPortalObject()
amount_list = parent_movement.getAggregatedAmountList(
amount_generator_type_list=portal.getPortalAmountGeneratorAllTypeList(1))
arrow_list = ['destination' + x[6:]
for x in parent_movement.getCategoryMembershipList(
('source', 'source_section'), base=True)]
if self.produce_at_source:
arrow_list = ['destination' + x[6:]
for x in parent_movement.getCategoryMembershipList(
('source', 'source_section'), base=True)]
else:
arrow_list = parent_movement.getCategoryMembershipList(
('destination', 'destination_section'), base=True)
def newMovement(reference, kw={}):
movement = aq_base(parent_movement.asContext(**kw)).__of__(
self._applied_rule)
......
......@@ -47,7 +47,7 @@ def _compare(tester_list, prevision_movement, decision_movement):
return False
return True
class MovementGeneratorMixin:
class MovementGeneratorMixin(object):
"""
This class provides a generic implementation of IMovementGenerator
which can be used together the Rule mixin class bellow. It does not
......
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