diff --git a/CHANGELOG b/CHANGELOG index 2a0f298541..a7690655c8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Allow consumable product on inventories * Let the user select a default warehouse * Add method to get default warehouse * Improve moves synchronisation on shipments diff --git a/inventory.py b/inventory.py index 4e7d29e4c4..23b5028dfd 100644 --- a/inventory.py +++ b/inventory.py @@ -246,8 +246,7 @@ class Inventory(Workflow, ModelSQL, ModelView): # Update existing lines for line in inventory.lines: - if not (line.product.type == 'goods' - and not line.product.consumable): + if line.product.type != 'goods': Line.delete([line]) continue @@ -297,7 +296,6 @@ class InventoryLine(ModelSQL, ModelView): product = fields.Many2One('product.product', 'Product', required=True, domain=[ ('type', '=', 'goods'), - ('consumable', '=', False), ], states=_states, depends=_depends) uom = fields.Function(fields.Many2One('product.uom', 'UOM', help="The unit in which the quantity is specified."), 'get_uom') diff --git a/location.xml b/location.xml index ef6ea2e2f0..9e8a91563d 100644 --- a/location.xml +++ b/location.xml @@ -75,6 +75,9 @@ this repository contains the full copyright notices and license terms. --> + stock.products_by_locations.context diff --git a/tests/scenario_stock_inventory.rst b/tests/scenario_stock_inventory.rst index d22b820c3b..4a0773ff0f 100644 --- a/tests/scenario_stock_inventory.rst +++ b/tests/scenario_stock_inventory.rst @@ -58,6 +58,18 @@ Create products:: >>> template2.save() >>> product2, = template2.products + >>> template = ProductTemplate() + >>> template.name = 'Product' + >>> template.default_uom = unit + >>> template.type = 'goods' + >>> template.consumable = True + >>> template.list_price = Decimal('300') + >>> template.cost_price_method = 'average' + >>> consumable, = template.products + >>> consumable.cost_price = Decimal('80') + >>> template.save() + >>> consumable, = template.products + Fill storage:: >>> StockMove = Model.get('stock.move') @@ -202,6 +214,27 @@ Empty storage:: 3.8 >>> inventory.click('confirm') +Add quantity of consumable product:: + + >>> inventory = Inventory() + >>> inventory.location = storage_loc + >>> inventory.empty_quantity = 'keep' + >>> line = inventory.lines.new() + >>> line.product = consumable + >>> line.quantity = 5.0 + >>> inventory.click('complete_lines') + >>> len(inventory.lines) + 1 + >>> inventory.click('confirm') + >>> line, = inventory.lines + >>> move, = line.moves + >>> move.quantity + 5.0 + >>> move.from_location == inventory.lost_found + True + >>> move.to_location == inventory.location + True + Create an inventory that should be empty after completion:: >>> Inventory = Model.get('stock.inventory') diff --git a/view/product_tree_qty.xml b/view/product_tree_qty.xml index 59e0822d33..9028e02868 100644 --- a/view/product_tree_qty.xml +++ b/view/product_tree_qty.xml @@ -8,4 +8,5 @@ this repository contains the full copyright notices and license terms. --> +