diff --git a/addons/account/res_config.py b/addons/account/res_config.py index 1cc814d8f75..8e9679eb74c 100644 --- a/addons/account/res_config.py +++ b/addons/account/res_config.py @@ -138,16 +138,6 @@ class account_config_settings(osv.osv_memory): string="Loss Exchange Rate Account", domain="[('type', '=', 'other')]"), } - def onchange_company_id(self, cr, uid, ids, company_id, context=None): - res = super(account_config_settings, self).onchange_company_id(cr, uid, ids, company_id, context=context) - if company_id: - company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) - res['value'].update({'income_currency_exchange_account_id': company.income_currency_exchange_account_id and company.income_currency_exchange_account_id.id or False, - 'expense_currency_exchange_account_id': company.expense_currency_exchange_account_id and company.expense_currency_exchange_account_id.id or False}) - else: - res['value'].update({'income_currency_exchange_account_id': False, - 'expense_currency_exchange_account_id': False}) - return res def _default_company(self, cr, uid, context=None): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) @@ -190,7 +180,6 @@ class account_config_settings(osv.osv_memory): else: return (time.strftime('%Y-01-01'), time.strftime('%Y-12-31'), 'month') - _defaults = { 'company_id': _default_company, 'has_default_company': _default_has_default_company, @@ -252,6 +241,12 @@ class account_config_settings(osv.osv_memory): 'default_sale_tax': isinstance(taxes_id, list) and taxes_id[0] or taxes_id, 'default_purchase_tax': isinstance(supplier_taxes_id, list) and supplier_taxes_id[0] or supplier_taxes_id, }) + # update gain/loss exchange rate accounts + values.update({ + 'income_currency_exchange_account_id': company.income_currency_exchange_account_id and company.income_currency_exchange_account_id.id or False, + 'expense_currency_exchange_account_id': company.expense_currency_exchange_account_id and company.expense_currency_exchange_account_id.id or False + }) + return {'value': values} def onchange_chart_template_id(self, cr, uid, ids, chart_template_id, context=None):