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,61 +310,48 @@ class SimulationMovement(Movement):
"""
return self.getRootAppliedRule().hasActivity(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getExplanation')
security.declareProtected( Permissions.AccessContentsInformation,
'getExplanation')
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
Name should be changed to generic name (getExplanationUid)
"""
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()
explanation_value = self.getExplanationValue()
if explanation_value is not None :
return explanation_value.getRelativeUrl()
security.declareProtected(Permissions.AccessContentsInformation, 'getExplanationUid')
security.declareProtected( Permissions.AccessContentsInformation,
'getExplanationUid')
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
Name should be changed to generic name (getExplanationUid)
explanation_value = self.getExplanationValue()
if explanation_value is not None :
return explanation_value.getUid()
security.declareProtected( Permissions.AccessContentsInformation,
'getExplanationValue')
def getExplanationValue(self):
"""Returns the delivery if any or the order related to the root
applied rule if any.
"""
if self.getDeliveryValue() is None:
ra = self.getRootAppliedRule()
order = ra.getCausalityValue()
if order is not None:
return order.getUid()
return order
else:
# Ex. zero stock rule
return ra.getUid()
return ra
else:
explanation_value = self.getDeliveryValue()
while explanation_value.getPortalType() not in self.getPortalDeliveryTypeList() and \
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()
security.declareProtected(Permissions.AccessContentsInformation, 'getExplanationValue')
def getExplanationValue(self):
"""
Returns the delivery if any or the order related to the root applied rule if any
Name should be changed to generic name (getExplanationUid)
"""
if self.getDeliveryValue() is None:
ra = self.getRootAppliedRule()
order = ra.getCausalityValue()
if order is not None:
return order
else:
# Ex. zero stock rule
return ra
else:
return self.getDeliveryValue()
return explanation_value
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