Commit a20ada38 authored by Jérome Perrin's avatar Jérome Perrin

if the delivery is not in a corresponding state to update applied rule, no need

to check if there's an applicable rule (just move the state test before
checking the rule existence)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25248 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c078c08d
...@@ -680,6 +680,12 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -680,6 +680,12 @@ class Delivery(XMLObject, ImmobilisationDelivery):
if rule_reference is None: if rule_reference is None:
return return
# only expand if we are not in a "too early" or "too late" state
if (self.getSimulationState() in
self.getPortalDraftOrderStateList()):
return
portal_rules = getToolByName(self, 'portal_rules') portal_rules = getToolByName(self, 'portal_rules')
res = portal_rules.searchFolder(reference=rule_reference, res = portal_rules.searchFolder(reference=rule_reference,
validation_state="validated", sort_on='version', validation_state="validated", sort_on='version',
...@@ -690,9 +696,6 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -690,9 +696,6 @@ class Delivery(XMLObject, ImmobilisationDelivery):
else: else:
raise NotFound('No such rule as %r is found' % (rule_reference,)) raise NotFound('No such rule as %r is found' % (rule_reference,))
# only expand if we are not in a "too early" or "too late" state
if (self.getSimulationState() not in
self.getPortalDraftOrderStateList()):
self._createAppliedRule(rule_id, force=force, **kw) self._createAppliedRule(rule_id, force=force, **kw)
def _createAppliedRule(self, rule_id, force=0, activate_kw=None, **kw): def _createAppliedRule(self, rule_id, force=0, activate_kw=None, **kw):
......
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