[FIX] stock: display the pack operations in the same order than the stock move (if possible)
This commit is contained in:
parent
d751c08e12
commit
0cbba7c222
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue