Commit 0c5fe26d authored by Julien Muchembled's avatar Julien Muchembled

Small optimization of SimulationMovement.getExplanationValue

parent 0be3a11a
...@@ -373,8 +373,8 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): ...@@ -373,8 +373,8 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
"""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.
""" """
delivery_value = self.getDeliveryValue() explanation_value = self.getDeliveryValue()
if delivery_value is None: if explanation_value is None:
# If the parent is not an Applied Rule, self does not have the method. # If the parent is not an Applied Rule, self does not have the method.
getRootAppliedRule = getattr(self, 'getRootAppliedRule', None) getRootAppliedRule = getattr(self, 'getRootAppliedRule', None)
if getRootAppliedRule is None: if getRootAppliedRule is None:
...@@ -386,16 +386,14 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): ...@@ -386,16 +386,14 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
else: else:
# Ex. zero stock rule # Ex. zero stock rule
return ra return ra
else: portal = self.getPortalObject()
explanation_value = delivery_value delivery_type_list = portal.getPortalDeliveryTypeList() \
portal = self.getPortalObject() + portal.getPortalOrderTypeList()
delivery_type_list = self.getPortalDeliveryTypeList() \ while explanation_value.getPortalType() not in delivery_type_list:
+ self.getPortalOrderTypeList() explanation_value = explanation_value.getParentValue()
while explanation_value.getPortalType() not in delivery_type_list and \ if explanation_value == portal:
explanation_value != portal: return
explanation_value = explanation_value.getParentValue() return explanation_value
if explanation_value != portal:
return explanation_value
# Deliverability / orderability # Deliverability / orderability
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
......
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