summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosse Colpaert <jco@openerp.com>2012-12-19 12:55:17 +0100
committerJosse Colpaert <jco@openerp.com>2012-12-19 12:55:17 +0100
commita02e894bfcad34945bceaf2a2ef97251555f2d78 (patch)
tree651b76bee09e5fabf742a06ce3f21e3404264ce5
parentdc47ad6c737e386d9ad163cb0cb39c6fe0c02724 (diff)
[FIX] Correction when no account or no company
bzr revid: jco@openerp.com-20121219115517-uj3t8embox155kty
-rw-r--r--addons/account_voucher/account_voucher.py13
1 files 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):