From 8e5aaae9bf38450a7c0d177e4f6d53d463e479f1 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Mon, 17 Oct 2011 17:21:47 +0200 Subject: [PATCH] [IMP] account: added a constraint on account_move_line in order to ensure that every journal entries of an account having a secondary currency, have the same secondary currency. bzr revid: qdp-launchpad@openerp.com-20111017152147-7kzht90bt711zzjr --- addons/account/account_move_line.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 2af05c3c82e..13803d3ff79 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -603,11 +603,19 @@ class account_move_line(osv.osv): return False return True + def _check_currency(self, cr, uid, ids, context=None): + for l in self.browse(cr, uid, ids, context=context): + if l.account_id.currency_id: + if not l.currency_id or not l.currency_id.id == l.account_id.currency_id.id: + return False + return True + _constraints = [ (_check_no_view, 'You can not create move line on view account.', ['account_id']), (_check_no_closed, 'You can not create move line on closed account.', ['account_id']), - (_check_company_id, 'Company must be same for its related account and period.',['company_id'] ), - (_check_date, 'The date of your Journal Entry is not in the defined period!',['date'] ), + (_check_company_id, 'Company must be same for its related account and period.', ['company_id']), + (_check_date, 'The date of your Journal Entry is not in the defined period!', ['date']), + (_check_currency, 'The selected account of your Journal Entry must receive a value in its secondary currency', ['currency_id']), ] #TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id