Browse Source

[FIX] account_financial_report: 2 things:

* Fix account group level computation

  Depends was not correct for recomputing when needed + better algorithm

* Make hide details on 0 work properly

  * Passing values to general ledger was stripping some correct records
  * Computed field for hiding lines doesn't have proper dependencies nor is not
    taking into account float currency accuracy
pull/749/head
Pedro M. Baeza 6 years ago
committed by João Marques
parent
commit
68c5261ab0
  1. 12
      account_financial_report/models/account_group.py
  2. 26
      account_financial_report/report/trial_balance.py

12
account_financial_report/models/account_group.py

@ -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',

26
account_financial_report/report/trial_balance.py

@ -3,6 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
from odoo.tools import float_is_zero
class TrialBalanceReport(models.TransientModel):
@ -114,16 +115,26 @@ class TrialBalanceReportAccount(models.TransientModel):
inverse_name='report_account_id'
)
@api.multi
@api.depends(
'currency_id',
'report_id',
'report_id.hide_account_at_0',
'report_id.limit_hierarchy_level',
'report_id.show_hierarchy_level',
'initial_balance',
'final_balance',
'debit',
'credit',
)
def _compute_hide_line(self):
for rec in self:
report = rec.report_id
rec.hide_line = False
r = (rec.currency_id or report.company_id.currency_id).rounding
if report.hide_account_at_0 and (
not rec.initial_balance and
not rec.final_balance and
not rec.debit and
not rec.credit):
float_is_zero(rec.initial_balance, precision_rounding=r)
and float_is_zero(rec.final_balance, precision_rounding=r)
and float_is_zero(rec.debit, precision_rounding=r)
and float_is_zero(rec.credit, precision_rounding=r)):
rec.hide_line = True
elif report.limit_hierarchy_level and \
rec.level > report.show_hierarchy_level:
@ -213,7 +224,8 @@ class TrialBalanceReportCompute(models.TransientModel):
'date_from': self.date_from,
'date_to': self.date_to,
'only_posted_moves': self.only_posted_moves,
'hide_account_at_0': self.hide_account_at_0,
# This is postprocessed later with a computed field
'hide_account_at_0': False,
'foreign_currency': self.foreign_currency,
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, account_ids.ids)],

Loading…
Cancel
Save