From b62f8a6469662f5d79bdd348bdb64c1cfe4cf077 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 30 Jan 2014 10:53:28 +0100 Subject: [PATCH] [FIX] When move is a return, assigned quants should have been processed by the original move bzr revid: jco@openerp.com-20140130095328-v63lo6dg1d951z2f --- addons/stock/stock.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 33c76f71959..df8afdb5f14 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1727,6 +1727,8 @@ class stock_move(osv.osv): fallback_domain = prev_quant_ids and [('id', 'not in', prev_quant_ids)] or [] #we always keep the quants already assigned and try to find the remaining quantity on quants not assigned only main_domain = [('reservation_id', '=', False), ('qty', '>', 0)] + if move.origin_returned_move_id: + main_domain += [('history_ids', 'in', move.origin_returned_move_id.id)] #first try to find quants based on specific domains given by linked operations for record in move.linked_move_operation_ids: domain = main_domain + self.pool.get('stock.move.operation.link').get_specific_domain(cr, uid, record, context=context) @@ -1792,6 +1794,8 @@ class stock_move(osv.osv): pickings.add(move.picking_id.id) qty = move.product_qty main_domain = [('qty', '>', 0)] + if move.origin_returned_move_id: + main_domain += [('history_ids', 'in', move.origin_returned_move_id.id)] prefered_domain = [('reservation_id', '=', move.id)] fallback_domain = [('reservation_id', '=', False)] #first, process the move per linked operation first because it may imply some specific domains to consider