From e4a21fbd7b1e2a1f5343f89ccdbd186aa1bb8bb1 Mon Sep 17 00:00:00 2001 From: "Ferdinand,mtr(OpenERP)" <> Date: Thu, 16 Jun 2011 15:00:21 +0530 Subject: [PATCH] [FIX] account: calculates the correct level lp bug: https://launchpad.net/bugs/783670 fixed bzr revid: mtr@mtr-20110616093021-n7ihs56l7v08ntwq --- addons/account/account.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index f6dd36c01fc..b3b6016fc74 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -340,9 +340,11 @@ class account_account(osv.osv): accounts = self.browse(cr, uid, ids, context=context) for account in accounts: level = 0 - if account.parent_id: - obj = self.browse(cr, uid, account.parent_id.id) - level = obj.level + 1 + parent_id = account.parent_id + while parent_id: + obj = self.browse(cr, uid, parent_id.id) + level += 1 + parent_id = obj.parent_id res[account.id] = level return res @@ -390,7 +392,10 @@ class account_account(osv.osv): 'manage this. So if you import from another software system you may have to use the rate at date. ' \ 'Incoming transactions always use the rate at date.', \ required=True), - 'level': fields.function(_get_level, string='Level', method=True, store=True, type='integer'), + 'level': fields.function(_get_level, string='Level', method=True, type='integer', + store={ + 'account.account': (lambda self, cr, uid, ids, c={}: ids, ['parent_id'], 10), + }), } _defaults = {