[Erp5-report] r17335 - /erp5/trunk/products/ERP5/MovementGroup.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Nov 1 04:09:50 CET 2007
Author: yo
Date: Thu Nov 1 04:09:49 2007
New Revision: 17335
URL: http://svn.erp5.org?rev=17335&view=rev
Log:
Fix a bug that QuantitySignMovementGroup may collect invalid movements (think about this order: 0, 1, -1). Also, simplify the code by cmp.
Modified:
erp5/trunk/products/ERP5/MovementGroup.py
Modified: erp5/trunk/products/ERP5/MovementGroup.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/MovementGroup.py?rev=17335&r1=17334&r2=17335&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/MovementGroup.py (original)
+++ erp5/trunk/products/ERP5/MovementGroup.py Thu Nov 1 04:09:49 2007
@@ -438,22 +438,17 @@
def __init__(self, movement, **kw):
RootMovementGroup.__init__(self, movement=movement, **kw)
quantity = movement.getQuantity()
- if quantity == 0:
- self.sign = 0
- elif quantity > 0:
- self.sign = 1
- else:
- self.sign = -1
+ self.sign = cmp(quantity, 0)
self.setGroupEdit(quantity_sign=self.sign)
def test(self, movement):
quantity = movement.getQuantity()
- if quantity == 0 or self.sign == 0 :
+ sign = cmp(quantity, 0)
+ if sign == 0:
return 1
- if quantity > 0:
- sign = 1
- else:
- sign = -1
+ if self.sign == 0:
+ self.sign = sign
+ return 1
return self.sign == sign
allow_class(QuantitySignMovementGroup)
More information about the Erp5-report
mailing list