[WIP] Take into account already returned moves

bzr revid: jco@openerp.com-20140129155638-q9nfmm728y2l03ae
This commit is contained in:
Josse Colpaert
2014-01-29 16:56:38 +01:00
parent 4370ed289f
commit e89b9b8539
2 changed files with 7 additions and 4 deletions
+2 -1
View File
@@ -1384,7 +1384,8 @@ class stock_move(osv.osv):
default['reserved_quant_ids'] = []
default['returned_move_ids'] = []
default['linked_move_operation_ids'] = []
default['origin_returned_move_id'] = False
if not default.get('origin_returned_move_id'):
default['origin_returned_move_id'] = False
default['state'] = 'draft'
return super(stock_move, self).copy_data(cr, uid, id, default, context)
+5 -3
View File
@@ -80,9 +80,11 @@ class stock_return_picking(osv.osv_memory):
raise osv.except_osv(_('Warning!'), _('You can not reverse when the chained moves are done!'))
#Search quants
quant_search = quant_obj.search(cr, uid, ['&', '&', ('history_ids', 'in', move.id), ('qty', '>', 0.0),
('location_id', '=', move.location_dest_id.id), ], context=context)
# ('reservation_id.origin_returned_move_id', '!=', move.id)
quants += [(move.id, x) for x in quant_obj.browse(cr, uid, quant_search, context=context)]
('location_id', 'child_of', move.location_dest_id.id), ], context=context)
quants += [(move.id, x) for x in quant_obj.browse(cr, uid, quant_search, context=context) if not x.reservation_id or x.reservation_id.origin_returned_move_id.id != move.id]
# Still need to group by move/product? (move has only one product => ...)
for quant in quants:
result1.append({'product_id': quant[1].product_id.id, 'quantity': quant[1].qty, 'move_id': quant[0]})