From 336192256d96dcecc7df93c2ba72909dd6e51174 Mon Sep 17 00:00:00 2001 From: "Achraf (abz)" Date: Thu, 19 Nov 2020 11:10:21 +0000 Subject: [PATCH] [FIX] stock: Show only affected products for lot_id name_search What are the steps to reproduce your issue ? 1. Install 'stock' 2. Create 'ProductA' with 'Tracking By Lots' 3. Create some 'Lots/Serial Numbers', for example 'CodeA0 and 'CodeA1' 4. Go to 'Reporting/Inventory Report' 5. Remove 'Product > Location' from the search bar. 6. Click 'Create' and select 'ProductA' with 'WH/Stock' Location What is currently happening ? When you set 'Lot/Serial Number', the available lots to choose are not limited to the selected product only. What are you expecting to happen ? Show only lots of the selected product. Why is this happening ? The domain contained no condition which depended on the product. How to fix the bug ? Addition of a condition that depends on the product. opw-238143 closes odoo/odoo#62046 X-original-commit: 3b33f1d3f5cb5182d5577176640bcf7427757ed2 Signed-off-by: Nicolas Martinelli (nim) --- addons/stock/models/stock_quant.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index eb8bebe6603..e7da386f1dd 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -33,10 +33,12 @@ class StockQuant(models.Model): ] if self.env.context.get('active_model') == 'product.product': domain.insert(0, "('product_id', '=', %s)" % self.env.context.get('active_id')) - if self.env.context.get('active_model') == 'product.template': + elif self.env.context.get('active_model') == 'product.template': product_template = self.env['product.template'].browse(self.env.context.get('active_id')) if product_template.exists(): domain.insert(0, "('product_id', 'in', %s)" % product_template.product_variant_ids.ids) + else: + domain.insert(0, "('product_id', '=', product_id)") return '[' + ', '.join(domain) + ']' def _domain_product_id(self):