From ac66f296aad9129251587faaa7c304de1716a494 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 31 Jan 2017 14:48:40 +0100 Subject: [PATCH] [FIX] stock: qty in pack operations - Enable lot tracking on Product A - UoM of Product A is kg, but Purchase UoM is lb(s) - Create a PO for 200 lb(s) of Product A, confirm - Go in the picking: 200.01 lb(s) shuold be received according to the pack operation, while 200.00 lb(s) are expected in the stock move. The field `product_qty` on the sotck move contains the quantity in kg, but already rounded from the value in lb(s). If we convert it back to lb(s), there might obviously be a rounding error, since we do: lb(s) -> kg -> lb(s) To solve this, we recompute the quantity in the UoM of the product without rounding, as a temporary computational value. opw-705259 --- addons/stock/models/stock_picking.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 55ac54287a5..83a83c3e10b 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -598,7 +598,10 @@ class Picking(models.Model): continue move_quants = move.reserved_quant_ids picking_quants += move_quants - forced_qty = (move.state == 'assigned') and move.product_qty - sum([x.qty for x in move_quants]) or 0 + forced_qty = 0.0 + if move.state == 'assigned': + qty = move.product_uom._compute_quantity(move.product_uom_qty, move.product_id.uom_id, round=False) + forced_qty = qty - sum([x.qty for x in move_quants]) # if we used force_assign() on the move, or if the move is incoming, forced_qty > 0 if float_compare(forced_qty, 0, precision_rounding=move.product_id.uom_id.rounding) > 0: if forced_qties.get(move.product_id):