Commit bde0f0c9 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Fix a bug that QuantitySignMovementGroup may collect invalid movements (think...

Fix a bug that QuantitySignMovementGroup may collect invalid movements (think about this order: 0, 1, -1). Also, simplify the code by cmp.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17335 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0220027a
...@@ -438,22 +438,17 @@ class QuantitySignMovementGroup(RootMovementGroup): ...@@ -438,22 +438,17 @@ class QuantitySignMovementGroup(RootMovementGroup):
def __init__(self, movement, **kw): def __init__(self, movement, **kw):
RootMovementGroup.__init__(self, movement=movement, **kw) RootMovementGroup.__init__(self, movement=movement, **kw)
quantity = movement.getQuantity() quantity = movement.getQuantity()
if quantity == 0: self.sign = cmp(quantity, 0)
self.sign = 0
elif quantity > 0:
self.sign = 1
else:
self.sign = -1
self.setGroupEdit(quantity_sign=self.sign) self.setGroupEdit(quantity_sign=self.sign)
def test(self, movement): def test(self, movement):
quantity = movement.getQuantity() quantity = movement.getQuantity()
if quantity == 0 or self.sign == 0 : sign = cmp(quantity, 0)
if sign == 0:
return 1
if self.sign == 0:
self.sign = sign
return 1 return 1
if quantity > 0:
sign = 1
else:
sign = -1
return self.sign == sign return self.sign == sign
allow_class(QuantitySignMovementGroup) allow_class(QuantitySignMovementGroup)
......
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