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