From 387c7abd2b4e82ba6078b867cc36b2b865302f7b Mon Sep 17 00:00:00 2001 From: JordiMForgeFlow Date: Wed, 19 May 2021 13:08:39 +0000 Subject: [FIX] mrp: fix recursion error when updating quants for kit variant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When updating the quantities available for a product, an inventory move is generated without setting the product_tmpl_id, as this field is related to the product_id of the move. However, when creating the move, Odoo will consider it a default missing value and will try to fill it in the method default_get. When navigating to the product variants of a template from the template form, a default_product_tmpl_id is set in the context pointing to the template. This context is propagated to the update quantity action to create/update quants for the variant. The problem when dealing with kits is that the products available to update their quantities are the components of the kit. When navigating to a variant and updating the quantities of a component of the kit variant, the default product template in the context will be the kit template. This is causing that, when generating the inventory move, the move is created with product_id of the component, and product_tmpl_id of the kit template. This issue creates a critical data inconsistency as the component's template is set to the kit's template, which apart from making no sense generates a recursion error. To fix this, when triggering the action to create/update quants for a kit product, it must be ensured that no default product template is being set. closes odoo/odoo#71055 X-original-commit: bdeea73dc1efb6ff7d02cc2f58347a69762bcc3c Signed-off-by: Rémy Voet --- addons/mrp/models/product.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/mrp/models/product.py b/addons/mrp/models/product.py index 110e82f0309..ade9617de7d 100644 --- a/addons/mrp/models/product.py +++ b/addons/mrp/models/product.py @@ -205,4 +205,5 @@ class ProductProduct(models.Model): res = super(ProductProduct, components).action_open_quants() if bom_kits: res['context']['single_product'] = False + res['context'].pop('default_product_tmpl_id', None) return res -- cgit v1.2.3