From 9cf22e5ef6e3e5f28b10d9be37a2c04b77785c0b Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Tue, 2 Oct 2018 11:26:36 +0000 Subject: [PATCH] [FIX] stock: inventory display archived product Usecase to reproduce: - Archive a stockable product with quantity on hand - Start an inventory with all products. -> Archived product is displayed It happens because the search is an SQL request that is build and it thus does not benefits from the automatic search on active objects. This commit add an active search on quant for inventory lines. Fixes #27302 closes odoo/odoo#27384 --- addons/stock/models/stock_inventory.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index fee89f0fa80..e1dbd631410 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -213,7 +213,7 @@ class Inventory(models.Model): def _get_inventory_lines_values(self): # TDE CLEANME: is sql really necessary ? I don't think so locations = self.env['stock.location'].search([('id', 'child_of', [self.location_id.id])]) - domain = ' location_id in %s' + domain = ' location_id in %s AND active = TRUE' args = (tuple(locations.ids),) vals = [] @@ -254,6 +254,8 @@ class Inventory(models.Model): self.env.cr.execute("""SELECT product_id, sum(quantity) as product_qty, location_id, lot_id as prod_lot_id, package_id, owner_id as partner_id FROM stock_quant + LEFT JOIN product_product + ON product_product.id = stock_quant.product_id WHERE %s GROUP BY product_id, location_id, lot_id, package_id, partner_id """ % domain, args)