[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
This commit is contained in:
Mayur Maheshwari (OpenERP) 2012-08-14 12:22:01 +05:30
parent 25367f13bb
commit 48f2640283
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -84,7 +84,7 @@
<group>
<field name="name"/>
<field name="user_valid"/>
<field name="currency_id" groups="base.group_multi_currency"/>
<field name="currency_id" groups="base.group_multi_currency" on_change="onchange_currency_id(currency_id)"/>
</group>
</group>
<notebook>