From 48f2640283326026a9df21e297f7ca351d2eadfd Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Tue, 14 Aug 2012 12:22:01 +0530 Subject: [PATCH] [FIX]hr_expense :put an onchange in the currency field that fill the force journal field with a purhcase journal that has the same currency bzr revid: mma@tinyerp.com-20120814065201-57472t4o0wma1232 --- addons/hr_expense/hr_expense.py | 8 ++++++++ addons/hr_expense/hr_expense_view.xml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index d860b21c125..ecd0c97f7e9 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -100,6 +100,14 @@ class hr_expense_expense(osv.osv): 'currency_id': _get_currency, } + def onchange_currency_id(self, cr, uid, ids, currency_id, context=None): + res = {'value': {'journal_id': False}} + company_id = self.browse(cr, uid, ids[0], context=context).company_id.id + journal_id = self.pool.get('account.journal').search(cr, uid, [('type','=','purchase'), ('currency','=',currency_id), ('company_id', '=', company_id)]) + if journal_id: + res['value']['journal_id'] = journal_id + return res + def onchange_employee_id(self, cr, uid, ids, employee_id, context=None): emp_obj = self.pool.get('hr.employee') department_id = False diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml index 1f9d49ee7c1..980b6e993c8 100644 --- a/addons/hr_expense/hr_expense_view.xml +++ b/addons/hr_expense/hr_expense_view.xml @@ -84,7 +84,7 @@ - +