[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
This commit is contained in:
Arnold Moyaux
2018-10-02 12:57:00 +00:00
parent 47369090db
commit 9cf22e5ef6
+3 -1
View File
@@ -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)