diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index f52bdeea89c..90f5992b584 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -401,6 +401,7 @@ class purchase_order(osv.osv):
return False
def action_cancel(self, cr, uid, ids, context=None):
+ wf_service = netsvc.LocalService("workflow")
for purchase in self.browse(cr, uid, ids, context=context):
for pick in purchase.picking_ids:
if pick.state not in ('draft','cancel'):
@@ -408,7 +409,6 @@ class purchase_order(osv.osv):
_('Unable to cancel this purchase order!'),
_('You must first cancel all receptions related to this purchase order.'))
for pick in purchase.picking_ids:
- wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr)
for inv in purchase.invoice_ids:
if inv and inv.state not in ('cancel','draft'):
@@ -416,10 +416,11 @@ class purchase_order(osv.osv):
_('Unable to cancel this purchase order!'),
_('You must first cancel all invoices related to this purchase order.'))
if inv:
- wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr)
self.write(cr,uid,ids,{'state':'cancel'})
- for (id,name) in self.name_get(cr, uid, ids):
+
+ for (id, name) in self.name_get(cr, uid, ids):
+ wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_cancel', cr)
message = _("Purchase order '%s' is cancelled.") % name
self.log(cr, uid, id, message)
return True
diff --git a/addons/purchase/purchase_workflow.xml b/addons/purchase/purchase_workflow.xml
index aea6fa2b2ac..c978712c0a1 100644
--- a/addons/purchase/purchase_workflow.xml
+++ b/addons/purchase/purchase_workflow.xml
@@ -138,12 +138,12 @@
- cancel
+ purchase_cancel
- cancel
+ purchase_cancel