From 75ffe3c712a8aabb6f8c1d00ed6642ba45439c4b Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 12:48:33 +0530 Subject: [PATCH] [IMP] account: use the new signal_xxx methods instead of trg_validate and also update code with create_workflow and delete_workflow feature. bzr revid: tta@openerp.com-20130201071833-x48y4zloat1diqa5 --- addons/account/wizard/account_invoice_refund.py | 5 +---- addons/account/wizard/account_invoice_state.py | 16 +++++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index 54d6c38a353..68937004dbc 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -23,7 +23,6 @@ import time from openerp.osv import fields, osv from openerp.tools.translate import _ -from openerp import netsvc class account_invoice_refund(osv.osv_memory): @@ -90,7 +89,6 @@ class account_invoice_refund(osv.osv_memory): account_m_line_obj = self.pool.get('account.move.line') mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') - wf_service = netsvc.LocalService('workflow') inv_tax_obj = self.pool.get('account.invoice.tax') inv_line_obj = self.pool.get('account.invoice.line') res_users_obj = self.pool.get('res.users') @@ -161,8 +159,7 @@ class account_invoice_refund(osv.osv_memory): to_reconcile_ids[line.account_id.id] = [line.id] if type(line.reconcile_id) != osv.orm.browse_null: reconcile_obj.unlink(cr, uid, line.reconcile_id.id) - wf_service.trg_validate(uid, 'account.invoice', \ - refund.id, 'invoice_open', cr) + inv_obj.signal_invoice_open(cr, uid, [refund.id]) refund = inv_obj.browse(cr, uid, refund_id[0], context=context) for tmpline in refund.move_id.line_id: if tmpline.account_id.id == inv.account_id.id: diff --git a/addons/account/wizard/account_invoice_state.py b/addons/account/wizard/account_invoice_state.py index f79b4c046e3..9fab19ff42c 100644 --- a/addons/account/wizard/account_invoice_state.py +++ b/addons/account/wizard/account_invoice_state.py @@ -21,7 +21,6 @@ from openerp.osv import osv from openerp.tools.translate import _ -from openerp import netsvc from openerp import pooler class account_invoice_confirm(osv.osv_memory): @@ -33,16 +32,16 @@ class account_invoice_confirm(osv.osv_memory): _description = "Confirm the selected invoices" def invoice_confirm(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService('workflow') if context is None: context = {} pool_obj = pooler.get_pool(cr.dbname) - data_inv = pool_obj.get('account.invoice').read(cr, uid, context['active_ids'], ['state'], context=context) - + account_invoice_obj = pool_obj.get('account.invoice') + data_inv = account_invoice_obj.read(cr, uid, context['active_ids'], ['state'], context=context) for record in data_inv: if record['state'] not in ('draft','proforma','proforma2'): raise osv.except_osv(_('Warning!'), _("Selected invoice(s) cannot be confirmed as they are not in 'Draft' or 'Pro-Forma' state.")) - wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_open', cr) + account_invoice_obj.signal_invoice_open(cr, uid, [ record['id'] ]) + return {'type': 'ir.actions.act_window_close'} account_invoice_confirm() @@ -59,14 +58,13 @@ class account_invoice_cancel(osv.osv_memory): def invoice_cancel(self, cr, uid, ids, context=None): if context is None: context = {} - wf_service = netsvc.LocalService('workflow') pool_obj = pooler.get_pool(cr.dbname) - data_inv = pool_obj.get('account.invoice').read(cr, uid, context['active_ids'], ['state'], context=context) - + account_invoice_obj = pool_obj.get('account.invoice') + data_inv = account_invoice_obj.read(cr, uid, context['active_ids'], ['state'], context=context) for record in data_inv: if record['state'] in ('cancel','paid'): raise osv.except_osv(_('Warning!'), _("Selected invoice(s) cannot be cancelled as they are already in 'Cancelled' or 'Done' state.")) - wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_cancel', cr) + account_invoice_obj.signal_invoice_cancel(cr , uid, [record['id']]) return {'type': 'ir.actions.act_window_close'} account_invoice_cancel()