From bc7582fc4c6b2424c01d1330558cd86d70938d94 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Wed, 23 Feb 2011 12:05:55 +0530 Subject: [PATCH] [Fix]: hr_expense: Invoicing an expense doesn't open the invoice form lp bug: https://launchpad.net/bugs/720629 fixed bzr revid: rha@tinyerp.com-20110223063555-q8is5wblqtp9ezg1 --- addons/hr_expense/hr_expense.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 6e19d953b95..ccce5de5375 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -125,15 +125,19 @@ class hr_expense_expense(osv.osv): return True def invoice(self, cr, uid, ids, context=None): + wf_service = netsvc.LocalService("workflow") mod_obj = self.pool.get('ir.model.data') - inv_id = self.action_invoice_create(cr, uid, ids) - res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form') + res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_tree') res_id = res and res[1] or False, - + for id in ids: + wf_service.trg_validate(uid, 'hr.expense.expense', id, 'invoice', cr) + inv_id = self.browse(cr, uid, id).invoice_id.id + if not inv_id: + raise osv.except_osv(_('Error'), _('No Invoice created')) return { 'name': 'Supplier Invoices', 'view_type': 'form', - 'view_mode': 'form', + 'view_mode': 'tree,form', 'view_id': [res_id], 'res_model': 'account.invoice', 'context': "{'type':'out_invoice', 'journal_type': 'purchase'}",