diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 0562f2fe289..ea8cf25beb6 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1268,7 +1268,8 @@ class stock_picking(osv.osv): prod2move_ids = {} still_to_do = [] #make a dictionary giving for each product, the moves and related quantity that can be used in operation links - for move in [x for x in picking.move_lines if x.state not in ('done', 'cancel')]: + moves = sorted([x for x in picking.move_lines if x.state not in ('done', 'cancel')], key=lambda x: (((x.state == 'assigned') and -2 or 0) + (x.partially_available and -1 or 0))) + for move in moves: if not prod2move_ids.get(move.product_id.id): prod2move_ids[move.product_id.id] = [{'move': move, 'remaining_qty': move.product_qty}] else: