From 82f88b06d61de3f1a186f6526260d2cb906682ca Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Tue, 22 Nov 2011 11:13:38 +0100 Subject: [PATCH] [IMP] account: added constraint on account_journal currency + changed default value of type field for new account_account bzr revid: qdp-launchpad@openerp.com-20111122101338-44k60vjsnmf3khud --- addons/account/account.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 630735c487f..c8895fa6946 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -461,7 +461,7 @@ class account_account(osv.osv): } _defaults = { - 'type': 'view', + 'type': 'other', 'reconcile': False, 'active': True, 'currency_mode': 'current', @@ -716,6 +716,19 @@ class account_journal(osv.osv): _order = 'code' + def _check_currency(self, cr, uid, ids, context=None): + for journal in self.browse(cr, uid, ids, context=context): + if journal.currency: + if journal.default_credit_account_id and not journal.default_credit_account_id.currency_id.id == journal.currency.id: + return False + if journal.default_debit_account_id and not journal.default_debit_account_id.currency_id.id == journal.currency.id: + return False + return True + + _constraints = [ + (_check_currency, 'Configuration error! The currency chosen should be shared by the default accounts too.', ['currency','default_debit_account_id','default_credit_account_id']), + ] + def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False): journal = self.browse(cr, uid, id, context=context) if not default: