From de3bc12c002a187eb44e311a9b58a8d90e9ea834 Mon Sep 17 00:00:00 2001 From: Barad Mahendra Date: Tue, 24 Nov 2020 10:39:02 +0000 Subject: [PATCH] [FIX] stock: Set default product on update qty wizard from variant Currently, when we update the Quantity from the 'Update quantity' button on a variant formview the product_id is not set due to reset of the context for product template. so in this commit, set the default product_id on update quantity wizard when open through the product form view and also keep default behaviour when called from product template. closes odoo/odoo#63141 Taskid: 2387310 X-original-commit: 49b8f1bfde1792079c0fd9cdb218eab20f344be3 Signed-off-by: Yannick Tivisse (yti) --- addons/stock/models/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 59809cf7226..e7ba523e50a 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -751,7 +751,7 @@ class ProductTemplate(models.Model): if (self.env.user.user_has_groups(','.join(advanced_option_groups))): return self.action_open_quants() else: - default_product_id = len(self.product_variant_ids) == 1 and self.product_variant_id.id + default_product_id = self.env.context.get('default_product_id', len(self.product_variant_ids) == 1 and self.product_variant_id.id) action = self.env["ir.actions.actions"]._for_xml_id("stock.action_change_product_quantity") action['context'] = dict( self.env.context,