Commit f81662b5 authored by Julien Muchembled's avatar Julien Muchembled

Delivery: simplify getRootCausalityValueList & isSimulated

Note that it is useless to test simulation quantity in isSimulated
because even if it exists, we already failed to find a related SM.
parent 3710e1d3
...@@ -339,18 +339,12 @@ class Delivery(XMLObject, ImmobilisationDelivery, ...@@ -339,18 +339,12 @@ class Delivery(XMLObject, ImmobilisationDelivery,
security.declareProtected(Permissions.AccessContentsInformation, 'isSimulated') security.declareProtected(Permissions.AccessContentsInformation, 'isSimulated')
def isSimulated(self): def isSimulated(self):
""" """
Returns 1 if all movements have a delivery or order counterpart Returns 1 if all non-null movements have a delivery counterpart
in the simulation in the simulation
""" """
for m in self.getMovementList(): for m in self.getMovementList():
#LOG('Delivery.isSimulated m',0,m.getPhysicalPath()) if m.getQuantity() and not m.isSimulated():
#LOG('Delivery.isSimulated m.isSimulated',0,m.isSimulated()) return 0
if not m.isSimulated():
#LOG('Delivery.isSimulated m.getQuantity',0,m.getQuantity())
#LOG('Delivery.isSimulated m.getSimulationQuantity',0,m.getSimulationQuantity())
if m.getQuantity() != 0.0 or m.getSimulationQuantity() not in (0, None):
return 0
# else Do we need to create a simulation movement ? XXX probably not
return 1 return 1
security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent') security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent')
...@@ -844,21 +838,21 @@ class Delivery(XMLObject, ImmobilisationDelivery, ...@@ -844,21 +838,21 @@ class Delivery(XMLObject, ImmobilisationDelivery,
This method will look at the causality and check if the This method will look at the causality and check if the
causality has already a causality causality has already a causality
""" """
causality_value_list = [x for x in self.getCausalityValueList() causality_value_list = self.getCausalityValueList()
if x is not self] if causality_value_list:
initial_list = [] initial_list = []
if len(causality_value_list)==0:
initial_list = [self]
else:
for causality in causality_value_list: for causality in causality_value_list:
# The causality may be something which has not this method # The causality may be something which has not this method
# (e.g. item) # (e.g. item)
if hasattr(causality, 'getRootCausalityValueList'): try:
tmp_causality_list = causality.getRootCausalityValueList() getRootCausalityValueList = causality.getRootCausalityValueList
initial_list.extend([x for x in tmp_causality_list except AttributeError:
if x not in initial_list]) continue
return initial_list assert causality != self
initial_list += [x for x in getRootCausalityValueList()
if x not in initial_list]
return initial_list
return [self]
# XXX Temp hack, should be removed has soon as the structure of # XXX Temp hack, should be removed has soon as the structure of
# the order/delivery builder will be reviewed. It might # the order/delivery builder will be reviewed. It might
......
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