From 2ac35cfca3e7e890be276d5561a0814964fbe08a Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 2 Feb 2010 22:37:52 +0100 Subject: [PATCH] [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 --- addons/purchase/purchase.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index ad1c2aef951..cc300516dd0 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -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={}):