Commit c4a30b06 authored by Guillaume Michon's avatar Guillaume Michon

Bug fix : use quantity of each item instead of number of items when calculating inventory


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4607 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2a6f3250
...@@ -71,11 +71,8 @@ class InventoryCell(DeliveryCell): ...@@ -71,11 +71,8 @@ class InventoryCell(DeliveryCell):
DeliveryCell._edit(self, REQUEST=REQUEST, force_update = force_update, **kw) DeliveryCell._edit(self, REQUEST=REQUEST, force_update = force_update, **kw)
# Calculate inventory # Calculate inventory
item_list = self.getAggregateValueList() item_list = self.getAggregateValueList()
if len(item_list) > 0: inventory = len(item_list)
inventory = 0 if inventory != 0:
for item in item_list:
if item.getQuantity() not in (None, ''):
inventory += item.getQuantity()
self.setInventory(inventory) self.setInventory(inventory)
......
...@@ -71,13 +71,11 @@ class InventoryLine(DeliveryLine): ...@@ -71,13 +71,11 @@ class InventoryLine(DeliveryLine):
DeliveryLine._edit(self, REQUEST=REQUEST, force_update = force_update, **kw) DeliveryLine._edit(self, REQUEST=REQUEST, force_update = force_update, **kw)
# Calculate inventory # Calculate inventory
item_list = self.getAggregateValueList() item_list = self.getAggregateValueList()
if len(item_list) > 0: if item_list is not None:
inventory = 0 inventory = len(item_list)
for item in item_list: if inventory != 0:
if item.getQuantity() not in (None, ''):
inventory += item.getQuantity()
self.setInventory(inventory) self.setInventory(inventory)
security.declareProtected(Permissions.AccessContentsInformation, 'getTotalInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getTotalInventory')
def getTotalInventory(self): def getTotalInventory(self):
...@@ -128,9 +126,7 @@ class InventoryLine(DeliveryLine): ...@@ -128,9 +126,7 @@ class InventoryLine(DeliveryLine):
inventory = self.getInventory() inventory = self.getInventory()
if current_inventory in (None, ''): if current_inventory in (None, ''):
current_inventory = 0.0 current_inventory = 0.0
LOG('return 1', 0, '%s - %s' % (repr(self.getInventory()), repr(current_inventory)))
return self.getInventory() - current_inventory return self.getInventory() - current_inventory
LOG('return 2', 0, repr(self.getInventory()))
return self.getInventory() return self.getInventory()
else: else:
return None return None
......
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