From 0cbba7c222eca8a306f2ff042904e2a7fee187c7 Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Mon, 19 Jan 2015 15:23:59 +0100 Subject: [PATCH] [FIX] stock: display the pack operations in the same order than the stock move (if possible) --- addons/stock/stock.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 260b953f034..a9a56e7b4b2 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1084,6 +1084,7 @@ class stock_picking(osv.osv): # Create the necessary operations for the grouped quants and remaining qtys uom_obj = self.pool.get('product.uom') + prevals = {} for key, qty in qtys_grouped.items(): product = self.pool.get("product.product").browse(cr, uid, key[0], context=context) uom_id = product.uom_id.id @@ -1091,7 +1092,7 @@ class stock_picking(osv.osv): if product_uom.get(key[0]): uom_id = product_uom[key[0]].id qty_uom = uom_obj._compute_qty(cr, uid, product.uom_id.id, qty, uom_id) - vals.append({ + val_dict = { 'picking_id': picking.id, 'product_qty': qty_uom, 'product_id': key[0], @@ -1101,7 +1102,17 @@ class stock_picking(osv.osv): 'location_id': key[4], 'location_dest_id': key[5], 'product_uom_id': uom_id, - }) + } + if key[0] in prevals: + prevals[key[0]].append(val_dict) + else: + prevals[key[0]] = [val_dict] + # prevals var holds the operations in order to create them in the same order than the picking stock moves if possible + processed_products = set() + for move in picking.move_lines: + if move.product_id.id not in processed_products: + vals += prevals.get(move.product_id.id, []) + processed_products.add(move.product_id.id) return vals @api.cr_uid_ids_context