[FIX] account_financial_report: Fix account group level computation

Depends was not correct for recomputing when needed + better algorithm
pull/489/head
Pedro M. Baeza 2019-01-07 14:53:51 +01:00
parent 922a38f8fa
commit 3b2f40e1f5
1 changed files with 5 additions and 7 deletions

View File

@ -25,15 +25,13 @@ class AccountGroup(models.Model):
string="Accounts", store=True)
@api.multi
@api.depends('parent_id')
@api.depends('parent_id', 'parent_id.level')
def _compute_level(self):
for group in self:
level = 0
new_group = group
while new_group.parent_id:
level += 1
new_group = new_group.parent_id
group.level = level
if not group.parent_id:
group.level = 0
else:
group.level = group.parent_id.level + 1
@api.multi
@api.depends('code_prefix', 'account_ids', 'account_ids.code',