Skip to content

Commit

Permalink
[FIX] mrp: update production quantity wizard factor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
beledouxdenis committed Feb 15, 2016
1 parent 4de3f4c commit ce38582
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addons/mrp/wizard/change_production_qty.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def change_prod_qty(self, cr, uid, ids, context=None):
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})
Expand All @@ -87,7 +88,7 @@ def change_prod_qty(self, cr, uid, ids, context=None):
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)
Expand Down

0 comments on commit ce38582

Please sign in to comment.