[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
This commit is contained in:
Arnold Moyaux
2018-10-15 15:05:56 +02:00
committed by Simon Lejeune
parent 17b6256955
commit dd501bbe37
+2 -1
View File
@@ -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,