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

isDivergent: fix docstring and return a boolean

parent d16118b7
......@@ -103,14 +103,10 @@ class Container(Movement, XMLObject):
security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent')
def isDivergent(self):
"""Return True if this movement diverges from the its simulation.
Containers are never divergent.
"""
Returns 1 if the target is not met according to the current information
After and edit, the isOutOfTarget will be checked. If it is 1,
a message is emitted
emit targetUnreachable !
"""
return 0
return False
def getContainerText(self):
"""
......
......@@ -72,12 +72,7 @@ class ContainerCell(DeliveryCell):
security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent')
def isDivergent(self):
"""Return True if this movement diverges from the its simulation.
Container Cells are never divergent.
"""
Returns 1 if the target is not met according to the current information
After and edit, the isOutOfTarget will be checked. If it is 1,
a message is emitted
emit targetUnreachable !
"""
# Never divergent
return 0
return False
......@@ -81,15 +81,10 @@ class ContainerLine(DeliveryLine):
security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent')
def isDivergent(self):
"""Return True if this movement diverges from the its simulation.
Container Lines are never divergent.
"""
Returns 1 if the target is not met according to the current information
After and edit, the isOutOfTarget will be checked. If it is 1,
a message is emitted
emit targetUnreachable !
"""
# Never divergent
return 0
return False
security.declareProtected(Permissions.AccessContentsInformation, 'getTotalQuantity')
def getTotalQuantity(self):
......
......@@ -334,7 +334,7 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
"""
Returns 0 if the target is not met
"""
return int(not self.isDivergent(**kw))
return bool(not self.isDivergent(**kw))
security.declareProtected(Permissions.AccessContentsInformation, 'isSimulated')
def isSimulated(self):
......@@ -349,20 +349,15 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent')
def isDivergent(self, fast=0, **kw):
"""
Returns 1 if the target is not met according to the current information
After and edit, the isOutOfTarget will be checked. If it is 1,
a message is emitted
emit targetUnreachable !
"""Return True if this movement diverges from the its simulation.
"""
## Note that fast option was removed. Now, fast=1 is ignored.
# Check if the total quantity equals the total of each simulation movement quantity
for simulation_movement in self._getAllRelatedSimulationMovementList():
if simulation_movement.isDivergent():
return 1
return 0
return True
return False
security.declareProtected(Permissions.AccessContentsInformation, 'getDivergenceList')
def getDivergenceList(self, **kw):
......
......@@ -488,13 +488,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
security.declareProtected( Permissions.AccessContentsInformation,
'isDivergent')
def isDivergent(self):
"""
XXX documentation out of sync with actual use
Returns 1 if the target is not met according to the current information
After and edit, the isOutOfTarget will be checked. If it is 1,
a message is emitted
emit targetUnreachable !
"""Return True if this movement diverges from the its simulation.
"""
for simulation_movement in self.getDeliveryRelatedValueList():
if simulation_movement.isDivergent():
......
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