From e2e4f433b41b18f69ba11229184378358f04915f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 5 Feb 2013 14:40:57 +0100
Subject: [PATCH] isDivergent: fix docstring and return a boolean

---
 product/ERP5/Document/Container.py     | 10 +++-------
 product/ERP5/Document/ContainerCell.py | 11 +++--------
 product/ERP5/Document/ContainerLine.py | 11 +++--------
 product/ERP5/Document/Delivery.py      | 15 +++++----------
 product/ERP5/Document/Movement.py      |  8 +-------
 5 files changed, 15 insertions(+), 40 deletions(-)

diff --git a/product/ERP5/Document/Container.py b/product/ERP5/Document/Container.py
index 5e82402673..349254ce87 100644
--- a/product/ERP5/Document/Container.py
+++ b/product/ERP5/Document/Container.py
@@ -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):
       """
diff --git a/product/ERP5/Document/ContainerCell.py b/product/ERP5/Document/ContainerCell.py
index 0c699a4fde..7e6a55cb6f 100644
--- a/product/ERP5/Document/ContainerCell.py
+++ b/product/ERP5/Document/ContainerCell.py
@@ -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
diff --git a/product/ERP5/Document/ContainerLine.py b/product/ERP5/Document/ContainerLine.py
index db41022d6b..d0783c7c3a 100644
--- a/product/ERP5/Document/ContainerLine.py
+++ b/product/ERP5/Document/ContainerLine.py
@@ -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):
diff --git a/product/ERP5/Document/Delivery.py b/product/ERP5/Document/Delivery.py
index 1afbe4aeb4..2bc2a7938a 100644
--- a/product/ERP5/Document/Delivery.py
+++ b/product/ERP5/Document/Delivery.py
@@ -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):
diff --git a/product/ERP5/Document/Movement.py b/product/ERP5/Document/Movement.py
index c9fc6b4a4f..5ba9ded36d 100644
--- a/product/ERP5/Document/Movement.py
+++ b/product/ERP5/Document/Movement.py
@@ -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():
-- 
2.30.9