From 25aea6a2bc0f1e4f4817b8728d4ee0ae8a34a077 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Thu, 30 Mar 2006 13:33:54 +0000 Subject: [PATCH] Added new MovementGroups. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6351 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/MovementGroup.py | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/product/ERP5/MovementGroup.py b/product/ERP5/MovementGroup.py index a9a16dcb74..3be844daca 100644 --- a/product/ERP5/MovementGroup.py +++ b/product/ERP5/MovementGroup.py @@ -39,6 +39,7 @@ from Products.PythonScripts.Utility import allow_class class MovementRejected(Exception) : pass class FakeMovementError(Exception) : pass +class MovementGroupError(Exception) : pass class RootMovementGroup: @@ -116,6 +117,12 @@ class RootMovementGroup: """ self._property_dict = kw + def updateGroupEdit(self, **kw): + """ + Update properties for the futur created object + """ + self._property_dict.update(kw) + def getGroupEditDict(self): """ Get property dict for the futur created object @@ -1001,3 +1008,44 @@ class SplitMovementGroup(RootMovementGroup): return 0 allow_class(AggregateMovementGroup) + +class TransformationAppliedRuleCausalityMovementGroup(RootMovementGroup): + """ + Groups movement that comes from simulation movement that shares the + same Production Applied Rule. + """ + def __init__(self, movement, **kw): + RootMovementGroup.__init__(self, movement=movement, **kw) + explanation_relative_url = self._getExplanationRelativeUrl(movement) + self.explanation = explanation_relative_url + explanation_value = movement.getPortalObject().restrictedTraverse( + explanation_relative_url) + self.setGroupEdit(causality_value=explanation_value) + + def _getExplanationRelativeUrl(self, movement): + """ Get the order value for a movement """ + transformation_applied_rule = movement.getParent() + transformation_rule = transformation_applied_rule.getSpecialiseValue() + if transformation_rule.getPortalType() != 'Transformation Rule': + raise MovementGroupError, 'movement! %s' % movement.getPath() + # XXX Dirty hardcoded + production_movement = transformation_applied_rule.pr + production_packing_list = production_movement.getExplanationValue() + return production_packing_list.getRelativeUrl() + + def test(self,movement): + return self._getExplanationRelativeUrl(movement) == self.explanation + +allow_class(TransformationAppliedRuleCausalityMovementGroup) + +class ParentExplanationCausalityMovementGroup(ParentExplanationMovementGroup): + """ + Like ParentExplanationMovementGroup, and set the causality. + """ + def __init__(self, movement, **kw): + ParentExplanationMovementGroup.__init__(self, movement=movement, **kw) + self.updateGroupEdit( + causality_value = self.explanation_value + ) + +allow_class(ParentExplanationCausalityMovementGroup) -- 2.30.9