diff --git a/addons/sale/sale.py b/addons/sale/sale.py index bdb87ad61f4..d115e81b601 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -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']]) line.refresh() #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): if (line.state == 'done') or not line.product_id: continue diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 2a316fa3461..8732ad93593 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2138,6 +2138,7 @@ class stock_move(osv.osv): """ procurement_obj = self.pool.get('procurement.order') context = context or {} + procs_to_check = [] for move in self.browse(cr, uid, ids, context=context): if move.state == 'done': 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) if move.procurement_id: # Does the same as procurement check, only eliminating a refresh - proc = move.procurement_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'}) - return self.write(cr, uid, ids, {'state': 'cancel', 'move_dest_id': False}, context=context) + procs_to_check.append(move.procurement_id.id) + + res = 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): pack_obj = self.pool.get("stock.quant.package")