Commit 1541c540 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Improved isSimulated


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@132 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent caa83aa1
...@@ -492,6 +492,10 @@ une liste de mouvements...""" ...@@ -492,6 +492,10 @@ une liste de mouvements..."""
security.declareProtected(Permissions.View, 'isSimulated') security.declareProtected(Permissions.View, 'isSimulated')
def isSimulated(self): def isSimulated(self):
"""
Returns 1 if all movements have a delivery or order counterpart
in the simulation
"""
for m in self.getMovementList(): for m in self.getMovementList():
if not m.isSimulated(): if not m.isSimulated():
return 0 return 0
......
...@@ -309,10 +309,8 @@ Une ligne tarifaire.""" ...@@ -309,10 +309,8 @@ Une ligne tarifaire."""
for cell in self.contentValues(filter={'portal_type': 'Delivery Cell'}): for cell in self.contentValues(filter={'portal_type': 'Delivery Cell'}):
if cell.isDivergent(): if cell.isDivergent():
return 1 return 1
if not cell.isSimulated():
return 1
else: else:
return Movement.isDivergent(self) or (not self.isSimulated()) return Movement.isDivergent(self)
security.declareProtected(Permissions.ModifyPortalContent, 'applyTargetSolver') security.declareProtected(Permissions.ModifyPortalContent, 'applyTargetSolver')
def applyTargetSolver(self, solver): def applyTargetSolver(self, solver):
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
from Globals import InitializeClass, PersistentMapping from Globals import InitializeClass, PersistentMapping
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.ERP5Globals import movement_type_list, draft_order_state
from Delivery import Delivery from Delivery import Delivery
...@@ -132,10 +133,20 @@ An order...""" ...@@ -132,10 +133,20 @@ An order..."""
) )
} }
security.declareProtected(Permissions.View, 'isDivergent')
def isDivergent(self):
"""
Returns 1 if not simulated or inconsistent target and values
"""
if self.getSimulationState() not in draft_order_state:
if not self.isSimulated():
return 1
return Delivery.isDivergent(self)
security.declareProtected(Permissions.ModifyPortalContent, 'updateAppliedRule') security.declareProtected(Permissions.ModifyPortalContent, 'updateAppliedRule')
def updateAppliedRule(self): def updateAppliedRule(self):
if self.getSimulationState() not in draft_order_state: if self.getSimulationState() not in draft_order_state:
# Nothing to do # Nothing to do if we are already simulated
self._createDeliveryRule() self._createDeliveryRule()
security.declareProtected(Permissions.ModifyPortalContent, '_createDeliveryRule') security.declareProtected(Permissions.ModifyPortalContent, '_createDeliveryRule')
...@@ -149,6 +160,7 @@ An order...""" ...@@ -149,6 +160,7 @@ An order..."""
# Look up if existing applied rule # Look up if existing applied rule
my_applied_rule_list = self.getCausalityRelatedValueList(portal_type='Applied Rule') my_applied_rule_list = self.getCausalityRelatedValueList(portal_type='Applied Rule')
if len(my_applied_rule_list) == 0: if len(my_applied_rule_list) == 0:
if self.isSimulated(): return # No need to create a DeliveryRule if we are already in the simulation process
# Create a new applied order rule (portal_rules.order_rule) # Create a new applied order rule (portal_rules.order_rule)
portal_rules = getToolByName(self, 'portal_rules') portal_rules = getToolByName(self, 'portal_rules')
portal_simulation = getToolByName(self, 'portal_simulation') portal_simulation = getToolByName(self, 'portal_simulation')
......
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