From 233ca1d56204cd4d7971e08c9860c33e699113c3 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 2 Apr 2015 12:52:59 +0200 Subject: [PATCH] [FIX] stock: do not consider moves which are done/canceled These moves are not taken into account when remaining quantity is computed or packs are prepared Fixes: #6030 opw: 631762 --- addons/stock/stock.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 69f15add962..99d2af904dc 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1042,7 +1042,7 @@ class stock_picking(osv.osv): # If we encounter an UoM that is smaller than the default UoM or the one already chosen, use the new one instead. product_uom = {} # Determines UoM used in pack operations - for move in picking.move_lines: + for move in [x for x in picking.move_lines if x.state not in ('done', 'cancel')]: if not product_uom.get(move.product_id.id): product_uom[move.product_id.id] = move.product_id.uom_id if move.product_uom.id != move.product_id.uom_id.id and move.product_uom.factor > product_uom[move.product_id.id].factor: @@ -1125,7 +1125,7 @@ class stock_picking(osv.osv): 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: + for move in [x for x in picking.move_lines if x.state not in ('done', 'cancel')]: if move.product_id.id not in processed_products: vals += prevals.get(move.product_id.id, []) processed_products.add(move.product_id.id) @@ -1236,7 +1236,7 @@ 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 picking.move_lines: + for move in [x for x in picking.move_lines if x.state not in ('done', 'cancel')]: if not prod2move_ids.get(move.product_id.id): prod2move_ids[move.product_id.id] = [{'move': move, 'remaining_qty': move.product_qty}] else: