Commit 70be507a authored by Julien Muchembled's avatar Julien Muchembled

OrderMovementGroup: small optimization (fixing wrong use of hasattr)

parent 96af08af
...@@ -39,10 +39,7 @@ class OrderMovementGroup(MovementGroup): ...@@ -39,10 +39,7 @@ class OrderMovementGroup(MovementGroup):
portal_type = 'Order Movement Group' portal_type = 'Order Movement Group'
def _getPropertyDict(self, movement, **kw): def _getPropertyDict(self, movement, **kw):
property_dict = {} return {'causality_list': [self._getOrderRelativeUrl(movement)]}
order_relative_url = self._getOrderRelativeUrl(movement)
property_dict['causality_list'] = [order_relative_url]
return property_dict
def test(self, movement, property_dict, **kw): def test(self, movement, property_dict, **kw):
if set(property_dict['causality_list']).issubset(movement.getCausalityList()): if set(property_dict['causality_list']).issubset(movement.getCausalityList()):
...@@ -52,16 +49,13 @@ class OrderMovementGroup(MovementGroup): ...@@ -52,16 +49,13 @@ class OrderMovementGroup(MovementGroup):
return False, property_dict return False, property_dict
def _getOrderRelativeUrl(self, movement): def _getOrderRelativeUrl(self, movement):
if hasattr(movement, 'getRootAppliedRule'): try:
getRootAppliedRule = movement.getRootAppliedRule
except AttributeError:
return # This is a temp movement
# This is a simulation movement # This is a simulation movement
order_relative_url = movement.getRootAppliedRule().getCausality( getCausality = getRootAppliedRule().getCausality
portal_type=movement.getPortalOrderTypeList()) return (getCausality(portal_type=movement.getPortalOrderTypeList()) or
if order_relative_url is None:
# In some cases (ex. DeliveryRule), there is no order # In some cases (ex. DeliveryRule), there is no order
# we may consider a PackingList as the order in the OrderGroup # we may consider a PackingList as the order in the OrderGroup
order_relative_url = movement.getRootAppliedRule().getCausality( getCausality(portal_type=movement.getPortalDeliveryTypeList()))
portal_type=movement.getPortalDeliveryTypeList())
else:
# This is a temp movement
order_relative_url = None
return order_relative_url
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