Commit 2be90dd3 authored by Jean-Paul Smets's avatar Jean-Paul Smets

getQuantity now takes into account pas movements in same node/section


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@365 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 91354e04
...@@ -140,7 +140,7 @@ Une ligne tarifaire.""" ...@@ -140,7 +140,7 @@ Une ligne tarifaire."""
elif produced_item_id_list is not None: elif produced_item_id_list is not None:
self._setProducedItemIdList(produced_item_id_list) self._setProducedItemIdList(produced_item_id_list)
elif consumed_item_id_list is not None: elif consumed_item_id_list is not None:
self._setConsumedItemIdList(consumed_item_id_list) self._setConsumedItemIdList(consumed_item_id_list)
security.declareProtected( Permissions.ModifyPortalContent, 'hasCellContent' ) security.declareProtected( Permissions.ModifyPortalContent, 'hasCellContent' )
def hasCellContent(self, base_id='movement'): def hasCellContent(self, base_id='movement'):
...@@ -180,11 +180,21 @@ Une ligne tarifaire.""" ...@@ -180,11 +180,21 @@ Une ligne tarifaire."""
quantity = self._baseGetQuantity() quantity = self._baseGetQuantity()
if quantity not in (0.0, 0, None): if quantity not in (0.0, 0, None):
return quantity return quantity
return self.getInventory()
# Find total of movements in the past - XXX # Find total of movements in the past - XXX
current_inventory = self.InventoryLine_zGetInventoryList( resource_value = self.getResourceValue()
section_uid = self.getDestinationSectionUid(), node_uid = getDestinationUid())[0].inventory if resource_value is not None:
return self.getInventory() - current_inventory # Inventories can only be done in "real" locations / sectinos, not categories thereof
# -> therefore we use node and section
current_inventory = resource_value.getInventory(
at_date = self.getStartDate(),
variation_text = self.getVariationText(),
node = self.getDestination(),
section = self.getDestinationSection())
inventory = self.getInventory()
if inventory in (None, ''):
return None # Do not change inventory if no inventory value provided
return self.getInventory() - current_inventory
return self.getInventory()
def _setItemIdList(self, value): def _setItemIdList(self, value):
""" """
......
...@@ -153,9 +153,20 @@ Une ligne tarifaire.""" ...@@ -153,9 +153,20 @@ Une ligne tarifaire."""
return quantity return quantity
return self.getInventory() return self.getInventory()
# Find total of movements in the past - XXX # Find total of movements in the past - XXX
current_inventory = self.InventoryLine_zGetInventoryList( resource_value = self.getResourceValue()
section_uid = self.getDestinationSectionUid(), node_uid = getDestinationUid())[0].inventory if resource_value is not None:
return self.getInventory() - current_inventory # Inventories can only be done in "real" locations / sectinos, not categories thereof
# -> therefore we use node and section
current_inventory = resource_value.getInventory(
at_date = self.getStartDate(),
variation_text = self.getVariationText(),
node = self.getDestination(),
section = self.getDestinationSection())
inventory = self.getInventory()
if inventory in (None, ''):
return None # Do not change inventory if no inventory value provided
return self.getInventory() - current_inventory
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