Commit 5d7e6a06 authored by Sebastien Robin's avatar Sebastien Robin

InventoryLine: like any other delivery line, use default quantity getter

This remove 12 years old compatibility code looking if some values where stored
in property "inventory".

This makes inventory line supporting default value, like getQuantity(1)
parent f9edce3b
...@@ -76,26 +76,6 @@ class InventoryLine(DeliveryLine): ...@@ -76,26 +76,6 @@ class InventoryLine(DeliveryLine):
total_quantity += cell.getInventory() total_quantity += cell.getInventory()
return total_quantity return total_quantity
security.declareProtected(Permissions.AccessContentsInformation,
'getQuantity')
def getQuantity(self):
"""
Computes a quantity which allows to reach inventory
"""
if not self.hasCellContent():
# First check if quantity already exists
quantity = self._baseGetQuantity()
if quantity not in (0.0,0,None):
return quantity
# Make sure inventory is defined somewhere (here or parent)
_marker = []
inventory = getattr(aq_base(self), 'inventory', _marker)
if inventory is not _marker and inventory is not None:
return inventory
return quantity
else:
return None
# Inventory cataloging # Inventory cataloging
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getConvertedInventory') 'getConvertedInventory')
......
...@@ -232,7 +232,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -232,7 +232,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory_list = sequence.get('inventory_list',[]) inventory_list = sequence.get('inventory_list',[])
inventory_line = inventory.newContent(portal_type = self.inventory_line_portal_type) inventory_line = inventory.newContent(portal_type = self.inventory_line_portal_type)
inventory_line.edit(resource_value = sequence.get('resource'), inventory_line.edit(resource_value = sequence.get('resource'),
inventory = 24. quantity = 24.
) )
inventory.deliver() inventory.deliver()
inventory_list.append(inventory) inventory_list.append(inventory)
...@@ -248,7 +248,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -248,7 +248,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory_line = inventory.newContent( inventory_line = inventory.newContent(
portal_type = self.inventory_line_portal_type, portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("second_resource"), resource_value = sequence.get("second_resource"),
inventory = 101) quantity = 101)
inventory.deliver() inventory.deliver()
inventory_list.append(inventory) inventory_list.append(inventory)
sequence.edit(inventory_list=inventory_list) sequence.edit(inventory_list=inventory_list)
...@@ -263,7 +263,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -263,7 +263,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory_line = inventory.newContent( inventory_line = inventory.newContent(
portal_type = self.inventory_line_portal_type, portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("second_resource"), resource_value = sequence.get("second_resource"),
inventory = 101) quantity = 101)
inventory.deliver() inventory.deliver()
inventory_list.append(inventory) inventory_list.append(inventory)
sequence.edit(inventory_list=inventory_list) sequence.edit(inventory_list=inventory_list)
...@@ -341,7 +341,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -341,7 +341,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory_line = inventory.newContent( inventory_line = inventory.newContent(
portal_type = self.inventory_line_portal_type, portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("second_resource"), resource_value = sequence.get("second_resource"),
inventory = 101) quantity = 101)
inventory.deliver() inventory.deliver()
def stepCreatePackingListForModule(self, sequence=None, def stepCreatePackingListForModule(self, sequence=None,
...@@ -2304,7 +2304,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -2304,7 +2304,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory_line = inventory.newContent( inventory_line = inventory.newContent(
portal_type=self.inventory_line_portal_type, portal_type=self.inventory_line_portal_type,
resource_value=resource_value, resource_value=resource_value,
inventory=inventory_quantity) quantity=inventory_quantity)
inventory.deliver() inventory.deliver()
inventory_list.append(inventory) inventory_list.append(inventory)
sequence.edit(inventory_list=inventory_list) sequence.edit(inventory_list=inventory_list)
......
...@@ -136,7 +136,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -136,7 +136,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
resource = sequence.get('resource_list')[-1] resource = sequence.get('resource_list')[-1]
inventory_line = inventory.newContent( inventory_line = inventory.newContent(
portal_type=self.inventory_line_portal_type) portal_type=self.inventory_line_portal_type)
inventory_line.edit(inventory=quantity, inventory_line.edit(quantity=quantity,
resource_value = resource) resource_value = resource)
return inventory return inventory
...@@ -171,7 +171,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -171,7 +171,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
""" """
quantity=self.default_quantity quantity=self.default_quantity
inventory_line = self.second_inventory.objectValues()[0] inventory_line = self.second_inventory.objectValues()[0]
inventory_line.edit(inventory=quantity) inventory_line.edit(quantity=quantity)
def stepCheckFirstNotVariatedInventory(self, start_date=None,quantity=None, def stepCheckFirstNotVariatedInventory(self, start_date=None,quantity=None,
...@@ -260,8 +260,8 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -260,8 +260,8 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
cell = inventory_line.newCell(base_id=base_id, cell = inventory_line.newCell(base_id=base_id,
portal_type=self.inventory_cell_portal_type, portal_type=self.inventory_cell_portal_type,
*cell_key) *cell_key)
cell.edit(mapped_value_property_list=['price','inventory'], cell.edit(mapped_value_property_list=['price','quantity'],
price=price, inventory=quantity, price=price, quantity=quantity,
predicate_category_list=cell_key, predicate_category_list=cell_key,
variation_category_list=cell_key,) variation_category_list=cell_key,)
if item_list is not None: if item_list is not None:
...@@ -306,7 +306,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -306,7 +306,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
destination_value=organisation) destination_value=organisation)
inventory_line = inventory.newContent( inventory_line = inventory.newContent(
portal_type=self.inventory_line_portal_type) portal_type=self.inventory_line_portal_type)
inventory_line.edit(inventory=quantity, inventory_line.edit(quantity=quantity,
resource_value = resource, resource_value = resource,
destination_value=organisation) destination_value=organisation)
......
...@@ -202,7 +202,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -202,7 +202,7 @@ class TestTradeReports(ERP5ReportTestCase):
inventory = self.inventory_module.newContent(portal_type='Inventory', **kw) inventory = self.inventory_module.newContent(portal_type='Inventory', **kw)
inventory_line = inventory.newContent(portal_type='Inventory Line', inventory_line = inventory.newContent(portal_type='Inventory Line',
resource=resource, resource=resource,
inventory=quantity) quantity=quantity)
if simulation_state == 'delivered': if simulation_state == 'delivered':
inventory.deliver() inventory.deliver()
...@@ -910,7 +910,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -910,7 +910,7 @@ class TestTradeReports(ERP5ReportTestCase):
portal_type='Inventory Cell', portal_type='Inventory Cell',
*cell_key) *cell_key)
cell.edit(mapped_value_property_list=['inventory'], cell.edit(mapped_value_property_list=['inventory'],
inventory=66, quantity=66,
predicate_category_list=cell_key, predicate_category_list=cell_key,
variation_category_list=cell_key) variation_category_list=cell_key)
fifth.deliver() fifth.deliver()
...@@ -1078,7 +1078,7 @@ class TestTradeReports(ERP5ReportTestCase): ...@@ -1078,7 +1078,7 @@ class TestTradeReports(ERP5ReportTestCase):
portal_type='Inventory Cell', portal_type='Inventory Cell',
*cell_key) *cell_key)
cell.edit(mapped_value_property_list=['inventory'], cell.edit(mapped_value_property_list=['inventory'],
inventory=66, quantity=66,
predicate_category_list=cell_key, predicate_category_list=cell_key,
variation_category_list=cell_key) variation_category_list=cell_key)
fifth.deliver() fifth.deliver()
......
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