[MERGE] Cancelling sale order should affect Procurements,production orders
authorRaphael Collet <rco@openerp.com>
Wed, 14 Sep 2011 14:17:35 +0000 (16:17 +0200)
committerRaphael Collet <rco@openerp.com>
Wed, 14 Sep 2011 14:17:35 +0000 (16:17 +0200)
bzr revid: rco@openerp.com-20110914141735-xysq4cvyagges1uc

1  2 
addons/sale/sale.py

@@@ -508,9 -509,15 +509,14 @@@ class sale_order(osv.osv)
                      raise osv.except_osv(
                          _('Could not cancel sale order !'),
                          _('You must first cancel all packing attached to this sale order.'))
+                 if pick.state == 'cancel':
+                     for mov in pick.move_lines:
+                         proc_ids = self.pool.get('mrp.procurement').search(cr, uid, [('move_id', '=', mov.id)])
+                         if proc_ids:
+                             for proc in proc_ids:
+                                 wf_service.trg_validate(uid, 'mrp.procurement', proc, 'button_check', cr)
              for r in self.read(cr, uid, ids, ['picking_ids']):
                  for pick in r['picking_ids']:
--                    wf_service = netsvc.LocalService("workflow")
                      wf_service.trg_validate(uid, 'stock.picking', pick, 'button_cancel', cr)
              for inv in sale.invoice_ids:
                  if inv.state not in ('draft', 'cancel'):
                          _('You must first cancel all invoices attached to this sale order.'))
              for r in self.read(cr, uid, ids, ['invoice_ids']):
                  for inv in r['invoice_ids']:
--                    wf_service = netsvc.LocalService("workflow")
                      wf_service.trg_validate(uid, 'account.invoice', inv, 'invoice_cancel', cr)
              sale_order_line_obj.write(cr, uid, [l.id for l in  sale.order_line],
                      {'state': 'cancel'})