From 72805c8ad407f7d1904233dd03fe8bcf943f4a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Grand-Guillaume?= Date: Fri, 26 Oct 2012 13:06:31 +0200 Subject: [PATCH] [IMP] Add a check on entries that user cannot provide a secondary currency if the same than the company one. bzr revid: joel.grandguillaume@camptocamp.com-20121026110631-vz7vx4ae0axabh14 --- addons/account/account_move_line.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index ffb9bb3ef0c..147fe7f76a4 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -626,6 +626,12 @@ class account_move_line(osv.osv): return False return True + def _check_currency_company(self, cr, uid, ids, context=None): + for l in self.browse(cr, uid, ids, context=context): + if l.currency_id.id == l.company_id.currency_id.id: + return False + return True + _constraints = [ (_check_no_view, 'You cannot create journal items on an account of type view.', ['account_id']), (_check_no_closed, 'You cannot create journal items on closed account.', ['account_id']), @@ -634,6 +640,7 @@ class account_move_line(osv.osv): (_check_currency, 'The selected account of your Journal Entry forces to provide a secondary currency. You should remove the secondary currency on the account or select a multi-currency view on the journal.', ['currency_id']), (_check_currency_and_amount, "You cannot create journal items with a secondary currency without recording both 'currency' and 'amount currency' field.", ['currency_id','amount_currency']), (_check_currency_amount, 'The amount expressed in the secondary currency must be positif when journal item are debit and negatif when journal item are credit.', ['amount_currency']), + (_check_currency_company, "You can't provide a secondary currency if the same than the company one." , ['currency_id']), ] #TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id