From dd501bbe3739b3f18d830363ad5582e21fdedca8 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Mon, 15 Oct 2018 13:47:47 +0200 Subject: [PATCH] [FIX] stock: replenish infinite loop with production Usecase to reproduce: - Create a BoM for a product with route Manufacture - Use replenish wizard in order to fill your stock It traceback due to an infinite loop. It happens because when the production order creates the raw moves, it does not set a product template. However a default_product template is in the context and is used as default value. So it creates a raw move with the component as product.product and the production product as template. Since they are related it will modify the product_tmpl_id of the product.product. It result by having a component with the finished product as template and it will use the same stock rules and bom again and again. This commit clean the context before running procurement rules. opw-1890661 --- addons/stock/wizard/product_replenish.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock/wizard/product_replenish.py b/addons/stock/wizard/product_replenish.py index ee426cb5939..133d901c04f 100644 --- a/addons/stock/wizard/product_replenish.py +++ b/addons/stock/wizard/product_replenish.py @@ -4,6 +4,7 @@ import datetime from odoo import api, fields, models from odoo.exceptions import UserError +from odoo.tools.misc import clean_context class ProductReplenish(models.TransientModel): @@ -51,7 +52,7 @@ class ProductReplenish(models.TransientModel): uom_reference = self.product_id.uom_id self.quantity = self.product_uom_id._compute_quantity(self.quantity, uom_reference) try: - self.env['procurement.group'].run( + self.env['procurement.group'].with_context(clean_context(self.env.context)).run( self.product_id, self.quantity, uom_reference,