From 77b6da1f20c1e3560fa6f82f65090688a2bf656a Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet <nicolas.dumazet@nexedi.com> Date: Fri, 2 Jul 2010 02:36:08 +0000 Subject: [PATCH] use xors git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36790 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/Movement.py | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/product/ERP5/Document/Movement.py b/product/ERP5/Document/Movement.py index e63ca185eb..eb6f3521cd 100644 --- a/product/ERP5/Document/Movement.py +++ b/product/ERP5/Document/Movement.py @@ -385,9 +385,7 @@ class Movement(XMLObject, Amount, CompositionMixin): """ result = self.getSourceInventoriatedTotalAssetPrice() if result is not None : - if result > 0 and not self.isCancellationAmount(): - return result - if result < 0 and self.isCancellationAmount(): + if (result > 0) ^ bool(self.isCancellationAmount()): return result return 0.0 @@ -399,9 +397,7 @@ class Movement(XMLObject, Amount, CompositionMixin): """ result = self.getSourceInventoriatedTotalAssetPrice() if result is not None : - if result < 0 and not self.isCancellationAmount(): - return -result - if result > 0 and self.isCancellationAmount(): + if (result < 0) ^ bool(self.isCancellationAmount()): return -result return 0.0 @@ -789,9 +785,7 @@ class Movement(XMLObject, Amount, CompositionMixin): quantity = float(quantity) except TypeError: quantity = 0.0 - if (quantity < 0 and not self.isCancellationAmount()): - return - quantity - elif quantity > 0 and self.isCancellationAmount(): + if (quantity < 0) ^ bool(self.isCancellationAmount()): return - quantity return 0.0 @@ -806,8 +800,7 @@ class Movement(XMLObject, Amount, CompositionMixin): quantity = float(quantity) except TypeError: quantity = 0.0 - if quantity < 0 and not self.isCancellationAmount() \ - or quantity > 0 and self.isCancellationAmount(): + if (quantity < 0) ^ bool(self.isCancellationAmount()): return 0.0 return quantity @@ -889,8 +882,7 @@ class Movement(XMLObject, Amount, CompositionMixin): quantity = float(quantity) except TypeError: quantity = 0.0 - if quantity < 0 and not self.isCancellationAmount() \ - or quantity > 0 and self.isCancellationAmount(): + if (quantity < 0) ^ bool(self.isCancellationAmount()): return 0.0 return quantity @@ -909,9 +901,7 @@ class Movement(XMLObject, Amount, CompositionMixin): quantity = float(quantity) except TypeError: quantity = 0.0 - if (quantity < 0 and not self.isCancellationAmount()): - return - quantity - elif quantity > 0 and self.isCancellationAmount(): + if (quantity < 0) ^ bool(self.isCancellationAmount()): return - quantity return 0.0 @@ -930,8 +920,7 @@ class Movement(XMLObject, Amount, CompositionMixin): quantity = float(quantity) except TypeError: quantity = 0.0 - if quantity < 0 and not self.isCancellationAmount() \ - or quantity > 0 and self.isCancellationAmount(): + if (quantity < 0) ^ bool(self.isCancellationAmount()): return 0.0 return quantity @@ -950,9 +939,7 @@ class Movement(XMLObject, Amount, CompositionMixin): quantity = float(quantity) except TypeError: quantity = 0.0 - if (quantity < 0 and not self.isCancellationAmount()): - return - quantity - elif quantity > 0 and self.isCancellationAmount(): + if (quantity < 0) ^ bool(self.isCancellationAmount()): return - quantity return 0.0 -- 2.30.9