Commit ea43b4e5 authored by Sebastien Robin's avatar Sebastien Robin

added method getRootCausalityValueList


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6043 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5462e4cc
...@@ -27,18 +27,13 @@ ...@@ -27,18 +27,13 @@
# #
############################################################################## ##############################################################################
from Globals import InitializeClass, PersistentMapping
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.CMFCore.WorkflowCore import WorkflowMethod from Products.CMFCore.WorkflowCore import WorkflowMethod
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.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.Base import Base from Products.ERP5.Document.Movement import Movement
from Products.ERP5.Document.DeliveryCell import DeliveryCell
from Products.ERP5.Document.ImmobilisationDelivery import ImmobilisationDelivery from Products.ERP5.Document.ImmobilisationDelivery import ImmobilisationDelivery
from Acquisition import Explicit, Implicit
from Products.PythonScripts.Utility import allow_class
from DateTime import DateTime
from zLOG import LOG from zLOG import LOG
...@@ -590,7 +585,7 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -590,7 +585,7 @@ class Delivery(XMLObject, ImmobilisationDelivery):
my_applied_rule.setCausalityValue(self) my_applied_rule.setCausalityValue(self)
# We must make sure this rule is indexed # We must make sure this rule is indexed
# now in order not to create another one later # now in order not to create another one later
my_applied_rule.reindexObject(**kw) my_applied_rule.reindexObject(activate_kw=activate_kw,**kw)
elif len(my_applied_rule_list) == 1: elif len(my_applied_rule_list) == 1:
# Re expand the rule if possible # Re expand the rule if possible
my_applied_rule = my_applied_rule_list[0] my_applied_rule = my_applied_rule_list[0]
...@@ -624,3 +619,35 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -624,3 +619,35 @@ class Delivery(XMLObject, ImmobilisationDelivery):
"Could not expand applied rule %s for delivery %s" %\ "Could not expand applied rule %s for delivery %s" %\
(applied_rule_id, self.getId())) (applied_rule_id, self.getId()))
security.declareProtected( Permissions.AccessContentsInformation,
'getInitialCausalityValueList')
def getRootCausalityValueList(self):
"""
Returns the initial causality value for this movement.
This method will look at the causality and check if the
causality has already a causality
"""
causality_value_list = self.getCausalityValueList()
initial_list = []
if len(causality_value_list)==0:
initial_list = [self]
else:
for causality in causality_value_list:
tmp_causality_list = causality.getRootCausalityValueList()
initial_list.extend([x for x in tmp_causality_list
if x not in initial_list])
return initial_list
# XXX Temp hack, should be removed has soon as the structure of
# the order/delivery builder will be reviewed. It might
# be reviewed if we plan to configure movement groups in the zmi
security.declareProtected( Permissions.ModifyPortalContent,
'setInitialCausalityValueList')
def setInitialCausalityValueList(self):
"""
This
"""
pass
...@@ -437,6 +437,17 @@ class Movement(XMLObject, Amount): ...@@ -437,6 +437,17 @@ class Movement(XMLObject, Amount):
Returns the object explanation of this movement. Returns the object explanation of this movement.
""" """
return self.getDeliveryValue() return self.getDeliveryValue()
security.declareProtected( Permissions.AccessContentsInformation,
'getInitialCausalityValueList')
def getRootCausalityValueList(self):
"""
Returns the initial causality value for this movement.
This method will look at the causality and check if the
causality has already a causality
"""
return self.getExplanationValue().getRootCausalityValueList()
# Simulation # Simulation
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
......
...@@ -198,7 +198,7 @@ class SimulationMovement(Movement): ...@@ -198,7 +198,7 @@ class SimulationMovement(Movement):
# Causality Workflow Methods # Causality Workflow Methods
security.declareProtected(Permissions.ModifyPortalContent, 'expand') security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, **kw): def expand(self, force=0, **kw):
""" """
Parses all existing applied rules and make sure they apply. Parses all existing applied rules and make sure they apply.
Checks other possible rules and starts expansion process Checks other possible rules and starts expansion process
...@@ -214,13 +214,13 @@ class SimulationMovement(Movement): ...@@ -214,13 +214,13 @@ class SimulationMovement(Movement):
# we know that invoicing rule acts like this, and that it comes after # we know that invoicing rule acts like this, and that it comes after
# invoice or invoicing_rule, so we if we come from invoince rule or # invoice or invoicing_rule, so we if we come from invoince rule or
# invoicing rule, we always expand regardless of the causality state. # invoicing rule, we always expand regardless of the causality state.
if (self.getParent().getSpecialiseId() not in if ((self.getParent().getSpecialiseId() not in
('default_invoicing_rule', 'default_invoice_rule') ('default_invoicing_rule', 'default_invoice_rule')
and self.getCausalityState() == 'expanded' ) or \ and self.getCausalityState() == 'expanded' ) or \
len(self.objectIds()) != 0: len(self.objectIds()) != 0):
# Reexpand # Reexpand
for my_applied_rule in self.objectValues(): for my_applied_rule in self.objectValues():
my_applied_rule.expand(**kw) my_applied_rule.expand(force=force,**kw)
else: else:
portal_rules = getToolByName(self, 'portal_rules') portal_rules = getToolByName(self, 'portal_rules')
# Parse each rule and test if it applies # Parse each rule and test if it applies
...@@ -228,7 +228,7 @@ class SimulationMovement(Movement): ...@@ -228,7 +228,7 @@ class SimulationMovement(Movement):
if rule.test(self): if rule.test(self):
my_applied_rule = rule.constructNewAppliedRule(self, **kw) my_applied_rule = rule.constructNewAppliedRule(self, **kw)
for my_applied_rule in self.objectValues() : for my_applied_rule in self.objectValues() :
my_applied_rule.expand(**kw) my_applied_rule.expand(force=force,**kw)
# Set to expanded # Set to expanded
self.setCausalityState('expanded') self.setCausalityState('expanded')
...@@ -523,6 +523,17 @@ class SimulationMovement(Movement): ...@@ -523,6 +523,17 @@ class SimulationMovement(Movement):
return root_simulation_movement.getUid() return root_simulation_movement.getUid()
return None return None
security.declareProtected( Permissions.AccessContentsInformation,
'getInitialCausalityValueList')
def getRootCausalityValueList(self):
"""
Returns the initial causality value for this movement.
This method will look at the causality and check if the
causality has already a causality
"""
root_rule = self.getRootAppliedRule()
return root_rule.getCausalityValueList()
# XXX FIXME Use a interaction workflow instead # XXX FIXME Use a interaction workflow instead
# XXX This behavior is now done by simulation_movement_interaction_workflow # XXX This behavior is now done by simulation_movement_interaction_workflow
# The call to activate() must be done after actual call to # The call to activate() must be done after actual call to
......
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