From 8ad6567fb73e9290a130e750bc0c39c6f2ed4e75 Mon Sep 17 00:00:00 2001 From: Ferdinand <> Date: Mon, 23 Jan 2012 14:44:29 +0530 Subject: [PATCH 1/2] [FIX] account : Error message for chart check must be user freindly lp bug: https://launchpad.net/bugs/919682 fixed bzr revid: mdi@tinyerp.com-20120123091429-pf4d65obqjtcn9ny --- addons/account/account.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 432a90a653e..3a84b6347f3 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1331,15 +1331,18 @@ class account_move(osv.osv): def button_validate(self, cursor, user, ids, context=None): for move in self.browse(cursor, user, ids, context=context): top = None + acc_line = None for line in move.line_id: account = line.account_id + if not acc_line: + acc_line = account while account: account2 = account account = account.parent_id if not top: top = account2.id elif top<>account2.id: - raise osv.except_osv(_('Error !'), _('You can not validate a journal entry unless all journal items belongs to the same chart of accounts !')) + raise osv.except_osv(_('Error !'), _('You can not validate a journal entry because account "%s" does not belong to the chart of accounts "%s"!'% (acc_line.name,account2.name))) return self.post(cursor, user, ids, context=context) def button_cancel(self, cr, uid, ids, context=None): From 4e39112275e1fb5abcf22ef30dbc1e537772567f Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 27 Jan 2012 16:56:47 +0100 Subject: [PATCH 2/2] [FIX] account: fix error message and misleading variable names bzr revid: rco@openerp.com-20120127155647-z83937bh3z8kbfjb --- addons/account/account.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 3a84b6347f3..5cf00404db5 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1330,19 +1330,17 @@ class account_move(osv.osv): def button_validate(self, cursor, user, ids, context=None): for move in self.browse(cursor, user, ids, context=context): - top = None - acc_line = None + # check that all accounts have the same topmost ancestor + top_common = None for line in move.line_id: account = line.account_id - if not acc_line: - acc_line = account - while account: - account2 = account - account = account.parent_id - if not top: - top = account2.id - elif top<>account2.id: - raise osv.except_osv(_('Error !'), _('You can not validate a journal entry because account "%s" does not belong to the chart of accounts "%s"!'% (acc_line.name,account2.name))) + top_account = account + while top_account.parent_id: + top_account = top_account.parent_id + if not top_common: + top_common = top_account + elif top_account.id != top_common.id: + raise osv.except_osv(_('Error !'), _('You cannot validate a journal entry because account "%s" does not belong to chart of accounts "%s"!' % (account.name, top_common.name))) return self.post(cursor, user, ids, context=context) def button_cancel(self, cr, uid, ids, context=None):