From bfb0f1e2a5d3a921bef89718e06c5f68da4f43ac Mon Sep 17 00:00:00 2001 From: len-odoo Date: Tue, 27 Nov 2018 13:05:34 +0000 Subject: [PATCH] [FIX] mrp: update unit_factor when updating MO quantity Set a BOM to create 10^k units of Product P, using n units of raw material R. On R, put rounding to 1 unit. Create a MO to produce 1 unit of P. Since it needs n/10^k units and rounding is set to 1, it sets 1 unit of R to consume. Now "update" (quantity to produce) to 10^k'. It correctly updates the quantity to consume. However, since it doesn't update the unit_factor, when you "produce", it will consume 10^k' units instead of 1. We copy the way the unit_factor is initially computed when updating the lines. opw 1903776 closes odoo/odoo#29067 --- addons/mrp/models/mrp_production.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index fef233c4d05..636d0abd8dc 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -440,6 +440,7 @@ class MrpProduction(models.Model): if move: if quantity > 0: move[0].write({'product_uom_qty': quantity}) + move.unit_factor = quantity / move.raw_material_production_id.product_qty elif quantity < 0: # Do not remove 0 lines if move[0].quantity_done > 0: raise UserError(_('Lines need to be deleted, but can not as you still have some quantities to consume in them. '))