Commit 502b45d5 authored by Jérome Perrin's avatar Jérome Perrin

unify the implementation of getExplanation[Value, Uid]


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3995 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5de79e55
...@@ -310,50 +310,31 @@ class SimulationMovement(Movement): ...@@ -310,50 +310,31 @@ class SimulationMovement(Movement):
""" """
return self.getRootAppliedRule().hasActivity(**kw) return self.getRootAppliedRule().hasActivity(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getExplanation') security.declareProtected( Permissions.AccessContentsInformation,
'getExplanation')
def getExplanation(self): def getExplanation(self):
"""Returns the delivery's relative_url if any or the order's
relative_url related to the root applied rule if any.
""" """
Returns the delivery if any or the order related to the root applied rule if any explanation_value = self.getExplanationValue()
Name should be changed to generic name (getExplanationUid) if explanation_value is not None :
""" return explanation_value.getRelativeUrl()
if self.getDeliveryValue() is None:
ra = self.getRootAppliedRule()
order = ra.getCausalityValue()
if order is not None:
return order.getRelativeUrl()
else:
# Ex. zero stock rule
return ra.getRelativeUrl()
else:
return self.getDelivery()
security.declareProtected(Permissions.AccessContentsInformation, 'getExplanationUid') security.declareProtected( Permissions.AccessContentsInformation,
'getExplanationUid')
def getExplanationUid(self): def getExplanationUid(self):
"""Returns the delivery's uid if any or the order's uid related to
the root applied rule if any.
""" """
Returns the delivery if any or the order related to the root applied rule if any explanation_value = self.getExplanationValue()
Name should be changed to generic name (getExplanationUid) if explanation_value is not None :
"""
if self.getDeliveryValue() is None:
ra = self.getRootAppliedRule()
order = ra.getCausalityValue()
if order is not None:
return order.getUid()
else:
# Ex. zero stock rule
return ra.getUid()
else:
explanation_value = self.getDeliveryValue()
while explanation_value.getPortalType() not in self.getPortalDeliveryTypeList() and \
explanation_value != self.getPortalObject():
explanation_value = explanation_value.getParent()
if explanation_value != self.getPortalObject():
return explanation_value.getUid() return explanation_value.getUid()
security.declareProtected(Permissions.AccessContentsInformation, 'getExplanationValue') security.declareProtected( Permissions.AccessContentsInformation,
'getExplanationValue')
def getExplanationValue(self): def getExplanationValue(self):
""" """Returns the delivery if any or the order related to the root
Returns the delivery if any or the order related to the root applied rule if any applied rule if any.
Name should be changed to generic name (getExplanationUid)
""" """
if self.getDeliveryValue() is None: if self.getDeliveryValue() is None:
ra = self.getRootAppliedRule() ra = self.getRootAppliedRule()
...@@ -364,7 +345,13 @@ class SimulationMovement(Movement): ...@@ -364,7 +345,13 @@ class SimulationMovement(Movement):
# Ex. zero stock rule # Ex. zero stock rule
return ra return ra
else: else:
return self.getDeliveryValue() explanation_value = self.getDeliveryValue()
while explanation_value.getPortalType() not in \
self.getPortalDeliveryTypeList() and \
explanation_value != self.getPortalObject():
explanation_value = explanation_value.getParent()
if explanation_value != self.getPortalObject():
return explanation_value
def isFrozen(self): def isFrozen(self):
""" """
......
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