[MERGE] trigger the workflow when canceling a purchase order.

bzr revid: vmt@openerp.com-20111110132059-b0n5591f5oc91469
This commit is contained in:
Vo Minh Thu 2011-11-10 14:20:59 +01:00
commit 35c3aabf0b
2 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -138,12 +138,12 @@
<record id="trans_except_picking" model="workflow.transition">
<field name="act_from" ref="act_except_picking"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">cancel</field>
<field name="signal">purchase_cancel</field>
</record>
<record id="trans_except_invoice" model="workflow.transition">
<field name="act_from" ref="act_except_invoice"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">cancel</field>
<field name="signal">purchase_cancel</field>
</record>
<record id="trans_picking_except_picking" model="workflow.transition">
<field name="act_from" ref="act_picking"/>