[MERGE] Sale: Cancelling sale order should affect Procurements,production orders

lp bug: https://launchpad.net/bugs/588220 fixed

bzr revid: mra@mra-laptop-20101217114853-kukmk0h8b1yes89c
This commit is contained in:
Mustufa Rangwala 2010-12-17 17:18:53 +05:30
commit 4ab460046a
1 changed files with 7 additions and 0 deletions

View File

@ -559,12 +559,19 @@ class sale_order(osv.osv):
if context is None:
context = {}
sale_order_line_obj = self.pool.get('sale.order.line')
proc_obj = self.pool.get('procurement.order')
for sale in self.browse(cr, uid, ids, context=context):
for pick in sale.picking_ids:
if pick.state not in ('draft', 'cancel'):
raise osv.except_osv(
_('Could not cancel sales order !'),
_('You must first cancel all picking attached to this sales order.'))
if pick.state == 'cancel':
for mov in pick.move_lines:
proc_ids = proc_obj.search(cr, uid, [('move_id', '=', mov.id)])
if proc_ids:
for proc in proc_ids:
wf_service.trg_validate(uid, 'procurement.order', proc, 'button_check', cr)
for r in self.read(cr, uid, ids, ['picking_ids']):
for pick in r['picking_ids']:
wf_service.trg_validate(uid, 'stock.picking', pick, 'button_cancel', cr)