[FIX] Make sure that when cancelling a move the linked procurements are checked the right way

This commit is contained in:
Josse Colpaert 2014-07-16 10:06:15 +02:00
parent 3b636a5df0
commit e23a36c1a5
2 changed files with 8 additions and 5 deletions

View File

@ -718,7 +718,7 @@ class sale_order(osv.osv):
procurement_obj.check(cr, uid, [x.id for x in line.procurement_ids if x.state not in ['cancel', 'done']]) procurement_obj.check(cr, uid, [x.id for x in line.procurement_ids if x.state not in ['cancel', 'done']])
line.refresh() line.refresh()
#run again procurement that are in exception in order to trigger another move #run again procurement that are in exception in order to trigger another move
proc_ids += [x.id for x in line.procurement_ids if x.state == 'exception'] proc_ids += [x.id for x in line.procurement_ids if x.state in ('exception', 'cancel')]
elif sale_line_obj.need_procurement(cr, uid, [line.id], context=context): elif sale_line_obj.need_procurement(cr, uid, [line.id], context=context):
if (line.state == 'done') or not line.product_id: if (line.state == 'done') or not line.product_id:
continue continue

View File

@ -2138,6 +2138,7 @@ class stock_move(osv.osv):
""" """
procurement_obj = self.pool.get('procurement.order') procurement_obj = self.pool.get('procurement.order')
context = context or {} context = context or {}
procs_to_check = []
for move in self.browse(cr, uid, ids, context=context): for move in self.browse(cr, uid, ids, context=context):
if move.state == 'done': if move.state == 'done':
raise osv.except_osv(_('Operation Forbidden!'), raise osv.except_osv(_('Operation Forbidden!'),
@ -2157,10 +2158,12 @@ class stock_move(osv.osv):
self.write(cr, uid, [move.move_dest_id.id], {'state': 'confirmed'}, context=context) self.write(cr, uid, [move.move_dest_id.id], {'state': 'confirmed'}, context=context)
if move.procurement_id: if move.procurement_id:
# Does the same as procurement check, only eliminating a refresh # Does the same as procurement check, only eliminating a refresh
proc = move.procurement_id procs_to_check.append(move.procurement_id.id)
if all([x.state == 'cancel' for x in proc.move_ids if x.id != move.id]):
procurement_obj.write(cr, uid, [proc.id], {'state': 'cancel'}) res = self.write(cr, uid, ids, {'state': 'cancel', 'move_dest_id': False}, context=context)
return self.write(cr, uid, ids, {'state': 'cancel', 'move_dest_id': False}, context=context) if procs_to_check:
procurement_obj.check(cr, uid, procs_to_check, context=context)
return res
def _check_package_from_moves(self, cr, uid, ids, context=None): def _check_package_from_moves(self, cr, uid, ids, context=None):
pack_obj = self.pool.get("stock.quant.package") pack_obj = self.pool.get("stock.quant.package")