From dfe96ff38eff06ecc649c3f779e5163c34266c22 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 19 Sep 2017 12:09:05 +0200 Subject: [PATCH] [FIX] stock: UoM on return lot - Create a product with: Product UoM: kg Purchase UoM: lb(s) Tracking: By lot(s) - Purchase 100 lb(s), validate and receive picking (set lot 001) - Return the picking - Set the lot The quantity to do is 45.36 instead of 100. We make sure to convert the quant UoM (=Product UoM) into the appropriate UoM. opw-771930 --- addons/stock/models/stock_picking.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 65aa42b69a5..e72ab2acc73 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -572,8 +572,11 @@ class Picking(models.Model): 'location_dest_id': mapping.location_dst_id, 'product_uom_id': uom.id, 'pack_lot_ids': [ - (0, 0, {'lot_id': lot, 'qty': 0.0, 'qty_todo': lots_grouped[mapping][lot]}) - for lot in lots_grouped.get(mapping, {}).keys()], + (0, 0, { + 'lot_id': lot, + 'qty': 0.0, + 'qty_todo': mapping.product.uom_id._compute_quantity(lots_grouped[mapping][lot], uom) + }) for lot in lots_grouped.get(mapping, {}).keys()], } product_id_to_vals.setdefault(mapping.product.id, list()).append(val_dict)