[FIX]: purchase: Fixed problem of cancelling PO was not cancelling related procurement, this was a problem of workflow of purchase order

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

bzr revid: rpa@tinyerp.com-20111109114908-oci1p59e636hebsr
This commit is contained in:
Rucha (Open ERP) 2011-11-09 17:19:08 +05:30
parent 1104277a61
commit daa579c9a3
2 changed files with 5 additions and 4 deletions

View File

@ -402,6 +402,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'):
@ -409,7 +410,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'):
@ -417,11 +417,12 @@ 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):
message = _("Purchase order '%s' is cancelled.") % name
wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_cancel', cr)
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"/>