def cancel_confirmed(self, cr, uid, ids, context=None):
obj = self.browse(cr,uid,ids,context)
active_id = int(obj.active_id)
active_model = obj.active_model
reason = obj.reason
if active_model == 'purchase.order':
self.pool.get('purchase.order').action_cancel(cr,uid,[active_id],context)
self.pool.get('purchase.order').write(cr,uid,[active_id],{'od_cancel_reason':reason},context)
elif active_model == 'stock.picking':
self.pool.get('stock.picking').action_cancel(cr,uid,[active_id],context)
self.pool.get('stock.picking').write(cr,uid,[active_id],{'od_cancel_reason':reason},context)
elif active_model == 'sale.order':
self.pool.get('sale.order').action_cancel(cr, uid, [active_id], context)
self.pool.get('sale.order').write(cr,uid,[active_id],{'od_cancel_reason':reason},context)
elif active_model == 'account.voucher':
self.pool.get('account.voucher').cancel_voucher(cr,uid,[active_id],context)
self.pool.get('account.voucher').write(cr,uid,[active_id],{'od_cancel_reason':reason},context)
return True
#account invoice written in new api
@api.multi
def action_cancel_for_invoice(self):
active_id = int(self.active_id)
reason= self.reason
acco = self.env['account.invoice'].browse(active_id)
acco.action_cancel()
acco.write({'od_cancel_reason': reason})
return True
No comments:
Post a Comment