diff --git a/account_financial_report/report/trial_balance.py b/account_financial_report/report/trial_balance.py index 192bd31c..43a5cb20 100644 --- a/account_financial_report/report/trial_balance.py +++ b/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)],