Comment 2 for bug 1075559

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : Re: [6.1] return product messed up when output location manually chained to customer location

For those affected by the bug, here is a patch for 6.1 that works around it.

=== modified file 'stock/wizard/stock_return_picking.py'
--- stock/wizard/stock_return_picking.py 2012-08-10 13:41:53 +0000
+++ stock/wizard/stock_return_picking.py 2012-11-27 15:17:10 +0000
@@ -188,6 +188,9 @@

             if returned_qty != new_qty:
                 set_invoice_state_to_none = False
+ current_move = move
+ if current_move.move_history_ids2:
+ current_move = current_move.move_history_ids2[0]
             if new_qty:
                 returned_lines += 1
                 new_move=move_obj.copy(cr, uid, move.id, {
@@ -195,7 +198,7 @@
                     'product_uos_qty': uom_obj._compute_qty(cr, uid, move.product_uom.id,
                         new_qty, move.product_uos.id),
                     'picking_id':new_picking, 'state':'draft',
- 'location_id':new_location, 'location_dest_id':move.location_id.id,
+ 'location_id':new_location, 'location_dest_id':current_move.location_id.id,
                     'date':date_cur,})
                 move_obj.write(cr, uid, [move.id], {'move_history_ids2':[(4,new_move)]})
         if not returned_lines: