From c0deb1f726462ca6cf341e56e9874f275b128587 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 11 May 2015 12:06:52 +0200 Subject: [PATCH] [FIX] sale_stock: check if moves are already done when cancelling a SO It prevents to cancel a SO for which moves are already done. opw-634415 --- addons/sale_stock/sale_stock.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 57634684e47..6827f5372e3 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -355,6 +355,14 @@ class sale_order_line(osv.osv): res.update({'warning': warning}) return res + def button_cancel(self, cr, uid, ids, context=None): + lines = self.browse(cr, uid, ids, context=context) + for procurement in lines.mapped('procurement_ids'): + for move in procurement.move_ids: + if move.state == 'done' and not move.scrapped: + raise osv.except_osv(_('Invalid Action!'), _('You cannot cancel a sale order line which is linked to a stock move already done.')) + return super(sale_order_line, self).button_cancel(cr, uid, ids, context=context) + class stock_move(osv.osv): _inherit = 'stock.move'