From 454a05a0da2111719dc9b91f493fa02247965ea2 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Thu, 5 Sep 2019 09:17:34 +0000 Subject: [PATCH] [FIX] stock: cant create lot for untracked product Before this commit, you can create production lot for product who isn't tracked. This commit add the condition in the domain. --- addons/stock/models/stock_production_lot.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/stock/models/stock_production_lot.py b/addons/stock/models/stock_production_lot.py index bb820e4a20b..a6594a55a52 100644 --- a/addons/stock/models/stock_production_lot.py +++ b/addons/stock/models/stock_production_lot.py @@ -33,10 +33,18 @@ class ProductionLot(models.Model): ] def _domain_product_id(self): - domain = "[('type', '=', 'product'), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" + domain = [ + "('tracking', '!=', 'none')", + "('type', '=', 'product')", + "'|'", + "('company_id', '=', False)", + "('company_id', '=', company_id)" + ] if self.env.context.get('default_product_tmpl_id'): - domain = "[('type', '=', 'product'), ('product_tmpl_id', '=', %s), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" % self.env.context['default_product_tmpl_id'] - return domain + domain.insert(0, + ("('product_tmpl_id', '=', %s)" % self.env.context['default_product_tmpl_id']) + ) + return '[' + ', '.join(domain) + ']' def _check_create(self): active_picking_id = self.env.context.get('active_picking_id', False)