[IMP] account: optimized code for calculating the level of accounts

bzr revid: mtr@tinyerp.com-20111024095600-w547t7m3r7hs6rmg
This commit is contained in:
Meera Trambadia (OpenERP) 2011-10-24 15:26:00 +05:30
parent 619f7304e7
commit 73a43b7e35
1 changed files with 8 additions and 9 deletions

View File

@ -340,11 +340,10 @@ class account_account(osv.osv):
accounts = self.browse(cr, uid, ids, context=context)
for account in accounts:
level = 0
parent_id = account.parent_id
while parent_id:
obj = self.browse(cr, uid, parent_id.id)
parent = account.parent_id
while parent:
level += 1
parent_id = obj.parent_id
parent = parent.parent_id
res[account.id] = level
return res