diff --git a/addons/account/res_config.py b/addons/account/res_config.py
index 72d30c11cfd..53c604161ea 100644
--- a/addons/account/res_config.py
+++ b/addons/account/res_config.py
@@ -151,12 +151,12 @@ class account_config_settings(osv.osv_memory):
self.write(cr, uid, [id], vals, context)
return id
- def onchange_company_id(self, cr, uid, ids, company_id):
+ def onchange_company_id(self, cr, uid, ids, company_id, context=None):
# update related fields
values = {}
values['currency_id'] = False
if company_id:
- company = self.pool.get('res.company').browse(cr, uid, company_id)
+ company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
has_chart_of_accounts = company_id not in self.pool.get('account.installer').get_unconfigured_cmp(cr, uid)
fiscalyear_count = self.pool.get('account.fiscalyear').search_count(cr, uid,
[('date_start', '<=', time.strftime('%Y-%m-%d')), ('date_stop', '>=', time.strftime('%Y-%m-%d')),
diff --git a/addons/account/res_config_view.xml b/addons/account/res_config_view.xml
index 4bfd3697d89..7977c0fc505 100644
--- a/addons/account/res_config_view.xml
+++ b/addons/account/res_config_view.xml
@@ -33,7 +33,7 @@
diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py
index d615eaf7d8c..b0176caa101 100644
--- a/addons/account_voucher/account_voucher.py
+++ b/addons/account_voucher/account_voucher.py
@@ -50,13 +50,25 @@ class account_config_settings(osv.osv_memory):
'company_id', 'income_currency_exchange_account_id',
type='many2one',
relation='account.account',
- string="Gain Exchange Rate Account"),
+ string="Gain Exchange Rate Account",
+ domain="[('type', '=', 'other')]"),
'expense_currency_exchange_account_id': fields.related(
'company_id', 'expense_currency_exchange_account_id',
type="many2one",
relation='account.account',
- string="Loss Exchange Rate Account"),
+ 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
class account_voucher(osv.osv):
def _check_paid(self, cr, uid, ids, name, args, context=None):