From ce385829076e91ac31e452269e96e0c10741bd67 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 15 Feb 2016 11:27:29 +0100 Subject: [PATCH] [FIX] mrp: update production quantity wizard factor Use the same factor than the one used when computing the products to consume at confirm. Before, the quantity of products to consume was wrong when using a different unit of measure in the BOM than in the production order. e.g. - BoM defined as: - 1 dozen of milk - BoM lines: 1 cow - Production order: - 1 unit of milk - BoM: The above one At confirm, the quantity to consume is 0,083 cow (1 cow / 12, this is correct) But, when updating the quantity to 2.0, it updated the quantity of cow to 24.0, instead of 0,16. opw-669447 --- addons/mrp/wizard/change_production_qty.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py index 74309b50825..c9ac13b3ce0 100644 --- a/addons/mrp/wizard/change_production_qty.py +++ b/addons/mrp/wizard/change_production_qty.py @@ -69,6 +69,7 @@ class change_production_qty(osv.osv_memory): prod_obj = self.pool.get('mrp.production') bom_obj = self.pool.get('mrp.bom') move_obj = self.pool.get('stock.move') + uom_obj = self.pool.get('product.uom') for wiz_qty in self.browse(cr, uid, ids, context=context): prod = prod_obj.browse(cr, uid, record_id, context=context) prod_obj.write(cr, uid, [prod.id], {'product_qty': wiz_qty.product_qty}) @@ -87,7 +88,7 @@ class change_production_qty(osv.osv_memory): if not bom_id: raise osv.except_osv(_('Error!'), _("Cannot find bill of material for this product.")) - factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor + factor = uom_obj._compute_qty(cr, uid, prod.product_uom.id, prod.product_qty, bom_point.product_uom.id) product_details, workcenter_details = \ bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, []) product_move = dict((mv.product_id.id, mv.id) for mv in prod.picking_id.move_lines)