[MERGE] lp:783670 about level computation of accounts

bzr revid: qdp-launchpad@openerp.com-20111026090010-ok929g2rb24qpk44
This commit is contained in:
Quentin (OpenERP) 2011-10-26 11:00:10 +02:00
commit c229d793b2
1 changed files with 11 additions and 7 deletions

View File

@ -350,9 +350,10 @@ 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 = account.parent_id
while parent:
level += 1
parent = parent.parent_id
res[account.id] = level
return res
@ -453,7 +454,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', store=True, type='integer'),
'level': fields.function(_get_level, string='Level', method=True, type='integer',
store={
'account.account': (_get_children_and_consol, ['level', 'parent_id'], 10),
}),
}
_defaults = {