[FIX] account: calculates the correct level

lp bug: https://launchpad.net/bugs/783670 fixed

bzr revid: mtr@mtr-20110616093021-n7ihs56l7v08ntwq
This commit is contained in:
Ferdinand,mtr(OpenERP) 2011-06-16 15:00:21 +05:30 committed by mtr
parent 2ed4fafe78
commit e4a21fbd7b
1 changed files with 9 additions and 4 deletions

View File

@ -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 = {