Commit 8bd2a320 authored by Jérome Perrin's avatar Jérome Perrin

base: don't use cmp in QuantitySignMovementGroup

parent 26e83ef6
...@@ -48,6 +48,13 @@ whether this is really required. ...@@ -48,6 +48,13 @@ whether this is really required.
from erp5.component.document.MovementGroup import MovementGroup from erp5.component.document.MovementGroup import MovementGroup
def _getSign(quantity):
if quantity == 0:
return 0
return 1 if quantity > 0 else -1
class QuantitySignMovementGroup(MovementGroup): class QuantitySignMovementGroup(MovementGroup):
""" """
The purpose of MovementGroup is to define how movements are grouped, The purpose of MovementGroup is to define how movements are grouped,
...@@ -59,7 +66,7 @@ class QuantitySignMovementGroup(MovementGroup): ...@@ -59,7 +66,7 @@ class QuantitySignMovementGroup(MovementGroup):
def _getPropertyDict(self, movement, **kw): def _getPropertyDict(self, movement, **kw):
property_dict = {} property_dict = {}
quantity = movement.getQuantity() quantity = movement.getQuantity()
property_dict['quantity_sign'] = cmp(quantity, 0) property_dict['quantity_sign'] = _getSign(quantity)
return property_dict return property_dict
def _separate(self, movement_list, **kw): def _separate(self, movement_list, **kw):
...@@ -68,7 +75,7 @@ class QuantitySignMovementGroup(MovementGroup): ...@@ -68,7 +75,7 @@ class QuantitySignMovementGroup(MovementGroup):
tmp_list = [[], [], []] # -1:minus, 0:zero, 1:plus tmp_list = [[], [], []] # -1:minus, 0:zero, 1:plus
for movement in movement_list: for movement in movement_list:
tmp_list[cmp(movement.getQuantity(), 0)].append(movement) tmp_list[_getSign(movement.getQuantity())].append(movement)
if len(tmp_list[1]): if len(tmp_list[1]):
if len(tmp_list[-1]): if len(tmp_list[-1]):
return[ return[
......
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