From fd54f58ccb7802af3aa8eff580affb29dceb9874 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 6 Mar 2013 17:39:31 +0100 Subject: [PATCH] [IMP] hr_expense: now propose to open the account.move in form view thanks to a button in the expense form view bzr revid: qdp-launchpad@openerp.com-20130306163931-609cgn16xmcr0wot --- addons/hr_expense/hr_expense.py | 25 +++++++++++++------------ addons/hr_expense/hr_expense_view.xml | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 9196cba3d96..cd11d19ff17 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -145,6 +145,9 @@ class hr_expense_expense(osv.osv): def expense_canceled(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'state': 'cancelled'}, context=context) + def action_receipt_create(self, cr, uid, ids, context=None): + raise osv.except_osv(_('Error!'), _('Deprecated function used')) + def account_move_get(self, cr, uid, expense_id, context=None): ''' This method prepare the creation of the account move related to the given expense. @@ -354,28 +357,26 @@ class hr_expense_expense(osv.osv): #'taxes':line.invoice_line_tax_id, } - - def action_receipt_create(self, cr, uid, ids, context=None): - raise osv.except_osv(_('Error!'), _('Deprecated function used')) - - def action_view_receipt(self, cr, uid, ids, context=None): - raise osv.except_osv(_('Error!'), _('Deprecated function used')) + def action_view_move(self, cr, uid, ids, context=None): ''' - This function returns an action that display existing receipt of given expense ids. + This function returns an action that display existing account.move of given expense ids. ''' assert len(ids) == 1, 'This option should only be used for a single id at a time' voucher_id = self.browse(cr, uid, ids[0], context=context).voucher_id.id - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_voucher', 'view_purchase_receipt_form') + try: + dummy, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'view_move_form') + except: + view_id = False result = { - 'name': _('Expense Receipt'), + 'name': _('Expense Account Move'), 'view_type': 'form', 'view_mode': 'form', - 'view_id': res and res[1] or False, - 'res_model': 'account.voucher', + 'view_id': view_id, + 'res_model': 'account.move', 'type': 'ir.actions.act_window', 'nodestroy': True, 'target': 'current', - 'res_id': voucher_id, + 'res_id': account_move_id, } return result diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml index cb1a7408a29..3ee97ba3a0e 100644 --- a/addons/hr_expense/hr_expense_view.xml +++ b/addons/hr_expense/hr_expense_view.xml @@ -67,7 +67,7 @@