From a02e894bfcad34945bceaf2a2ef97251555f2d78 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Wed, 19 Dec 2012 12:55:17 +0100 Subject: [PATCH] [FIX] Correction when no account or no company bzr revid: jco@openerp.com-20121219115517-uj3t8embox155kty --- addons/account_voucher/account_voucher.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 59399a766d5..609a19661c0 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -49,19 +49,24 @@ 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): res = super(account_config_settings, self).onchange_company_id(cr, uid, ids, company_id) if company_id: company = self.pool.get('res.company').browse(cr, uid, company_id) - res['value'].update({'income_currency_exchange_account_id': company.income_currency_exchange_account_id and company.income_currency_exchange_account_id.id, - 'expense_currency_exchange_account_id': company.expense_currency_exchange_account_id and company.expense_currency_exchange_account_id.id}) + 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):