[FIX] account: res_config: gain/loss exch. account onchange

Commit f4e350ca3 defined an `onchange_company_id` method, never executed
because another `onchange_company_id` was defined below. Merged the first
in the second.
This commit is contained in:
Simon Lejeune 2014-10-06 14:30:23 +02:00
parent 1029dbc4f3
commit e388cb8c32
1 changed files with 6 additions and 11 deletions

View File

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