From 37f945961071c6905e5b4aadb629c2f1255018b8 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 17 Feb 2015 11:43:49 +0100 Subject: [PATCH] [IMP] Return of return should be linked with original destination move should fix #5253 [FIX] Split of return move should keep the returned move [IMP] Better comment and check for state not cancelled --- addons/stock/stock.py | 1 + addons/stock/wizard/stock_return_picking.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 9c1bb5dd55b..7a694f7cc32 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2514,6 +2514,7 @@ class stock_move(osv.osv): 'split_from': move.id, 'procurement_id': move.procurement_id.id, 'move_dest_id': move.move_dest_id.id, + 'origin_returned_move_id': move.origin_returned_move_id.id, } if context.get('source_location_id'): defaults['location_id'] = context['source_location_id'] diff --git a/addons/stock/wizard/stock_return_picking.py b/addons/stock/wizard/stock_return_picking.py index deb624ea797..29b83d9200f 100644 --- a/addons/stock/wizard/stock_return_picking.py +++ b/addons/stock/wizard/stock_return_picking.py @@ -132,6 +132,12 @@ class stock_return_picking(osv.osv_memory): raise osv.except_osv(_('Warning !'), _("You have manually created product lines, please delete them to proceed")) new_qty = data_get.quantity if new_qty: + # The return of a return should be linked with the original's destination move if it was not cancelled + if move.origin_returned_move_id.move_dest_id.id and move.origin_returned_move_id.move_dest_id.state != 'cancel': + move_dest_id = move.origin_returned_move_id.move_dest_id.id + else: + move_dest_id = False + returned_lines += 1 move_obj.copy(cr, uid, move.id, { 'product_id': data_get.product_id.id, @@ -144,6 +150,7 @@ class stock_return_picking(osv.osv_memory): 'origin_returned_move_id': move.id, 'procure_method': 'make_to_stock', 'restrict_lot_id': data_get.lot_id.id, + 'move_dest_id': move_dest_id, }) if not returned_lines: