[FIX] Properly cancel a draft purchase.order when unlinking it, so correct workflow signals can be propagated to parent workflows if there are any.

Note: in trunk a different mechanism should be added to automatically propagate e.g. a subflow.delete signal whenever a record with a parent workflow is unlinked. This would allow adding an explicit transition from the subflow node in the parent flow for these kind of cases.

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

bzr revid: odo@openerp.com-20100202213752-lffj73sbobyw6ygk
This commit is contained in:
Olivier Dony 2010-02-02 22:37:52 +01:00
parent fff40de35d
commit 2ac35cfca3
1 changed files with 7 additions and 0 deletions

View File

@ -217,6 +217,13 @@ class purchase_order(osv.osv):
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Purchase Order(s) which are in %s State!' % s['state']))
# TODO: temporary fix in 5.0, to remove in 5.2 when subflows support
# automatically sending subflow.delete upon deletion
wf_service = netsvc.LocalService("workflow")
for id in unlink_ids:
wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_cancel', cr)
return super(purchase_order, self).unlink(cr, uid, unlink_ids, context=context)
def button_dummy(self, cr, uid, ids, context={}):