From c27a906cbd8e40cee7dc0e41d9eba489ef58a443 Mon Sep 17 00:00:00 2001 From: sergiocorato Date: Thu, 22 Sep 2022 20:46:40 +0200 Subject: [PATCH] [FIX][12.0] l10n_it_account_balance_report --- .../report/account_balance_report.py | 18 +++++++++++++++-- .../report/account_balance_report_xlsx.py | 20 ++++++++++++++----- .../templates/account_balance_report.xml | 4 ++-- .../report/trial_balance_report.py | 4 +++- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/l10n_it_account_balance_report/report/account_balance_report.py b/l10n_it_account_balance_report/report/account_balance_report.py index 0addce3f2e5c..9b35ea4bc19e 100644 --- a/l10n_it_account_balance_report/report/account_balance_report.py +++ b/l10n_it_account_balance_report/report/account_balance_report.py @@ -129,8 +129,10 @@ def compute_data_for_report(self): sign = trial_acc_line.get_balance_sign() trial_acc_line.final_balance *= sign + trial_acc_line.period_balance *= sign for trial_partner_line in trial_acc_line.partner_ids: trial_partner_line.final_balance *= sign + trial_partner_line.period_balance *= sign balance_line_vals = ( 0, 0, { @@ -150,11 +152,23 @@ def compute_data_for_report(self): if section == r_sec: section_credit_vals.append(balance_line_vals) if not trial_acc_line.account_group_id: - total_credit += trial_acc_line.final_balance + # get total from period when we create a profit/loss report + total_credit += ( + trial_acc_line.period_balance if + trial_acc_line.account_id.internal_group in + ["income", "expense"] + else trial_acc_line.final_balance + ) elif section == l_sec: section_debit_vals.append(balance_line_vals) if not trial_acc_line.account_group_id: - total_debit += trial_acc_line.final_balance + # get total from period when we create a profit/loss report + total_debit += ( + trial_acc_line.period_balance if + trial_acc_line.account_id.internal_group in + ["income", "expense"] + else trial_acc_line.final_balance + ) curr = self.company_id.currency_id or self.company_id._get_euro() digits = curr.decimal_places diff --git a/l10n_it_account_balance_report/report/account_balance_report_xlsx.py b/l10n_it_account_balance_report/report/account_balance_report_xlsx.py index 5ead54643c80..90576a460afa 100644 --- a/l10n_it_account_balance_report/report/account_balance_report_xlsx.py +++ b/l10n_it_account_balance_report/report/account_balance_report_xlsx.py @@ -151,19 +151,23 @@ def _get_report_columns(self, report): 'indent_field': 'level', 'indent_unit': 2, 'width': 60}, - 2: {'field': 'final_balance', + 2: {'field': 'period_balance', + 'header': _("Period balance"), + 'type': 'amount', + 'width': 20}, + 3: {'field': 'final_balance', 'header': _("Final balance"), 'type': 'amount', 'width': 20} } if report.foreign_currency: cols.update({ - 3: {'field': 'currency_id', + 4: {'field': 'currency_id', 'field_currency_balance': 'currency_id', 'header': _("Cur."), 'type': 'many2one', 'width': 10}, - 4: {'field': 'final_balance_foreign_currency', + 5: {'field': 'final_balance_foreign_currency', 'header': _("Ending balance in cur."), 'type': 'amount_currency', 'width': 20} @@ -199,7 +203,10 @@ def generate_partner_columns(self, cols, mode): 1: {'field': 'partner_id', 'type': 'many2one', 'width': 60}, - 2: {'field': 'final_balance', + 2: {'field': 'period_balance', + 'type': 'amount', + 'width': 20}, + 3: {'field': 'final_balance', 'type': 'amount', 'width': 20} }) @@ -210,7 +217,10 @@ def generate_partner_columns(self, cols, mode): 1 + len(cols): {'field': 'partner_id', 'type': 'many2one', 'width': 60}, - 2 + len(cols): {'field': 'final_balance', + 2 + len(cols): {'field': 'period_balance', + 'type': 'amount', + 'width': 20}, + 3 + len(cols): {'field': 'final_balance', 'type': 'amount', 'width': 20} }) diff --git a/l10n_it_account_balance_report/report/templates/account_balance_report.xml b/l10n_it_account_balance_report/report/templates/account_balance_report.xml index 40cda0fe5a37..c640e60d3ed4 100644 --- a/l10n_it_account_balance_report/report/templates/account_balance_report.xml +++ b/l10n_it_account_balance_report/report/templates/account_balance_report.xml @@ -216,7 +216,7 @@ t-att-data-res-model="'account.move.line'" class="o_account_financial_reports_web_action_monetary_multi" t-att-style="style"> - + @@ -229,7 +229,7 @@ t-att-data-res-model="'account.move.line'" class="o_account_financial_reports_web_action_monetary_multi" t-att-style="style"> - + diff --git a/l10n_it_account_balance_report/report/trial_balance_report.py b/l10n_it_account_balance_report/report/trial_balance_report.py index cc761142fb1b..bdc16bc0f8fb 100644 --- a/l10n_it_account_balance_report/report/trial_balance_report.py +++ b/l10n_it_account_balance_report/report/trial_balance_report.py @@ -31,7 +31,9 @@ def _compute_hide_line(self): # lines_to_recompute will be self itself. for line in lines_to_recompute: trial_report = line.report_id - balance = line.final_balance + balance = line.period_balance if line.account_id.internal_group in [ + "income", "expense" + ] else line.final_balance currency = line.currency_id or trial_report.company_id.currency_id rounding = currency.rounding if trial_report.hide_account_at_0 \