From f43b481a074725543eb7b0805fe3eff229cfd8cc Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 23 Oct 2024 16:58:03 +0200 Subject: [PATCH 1/5] [FIX] account_financial_report: in XLSX report, display null ending balance (just like we display null initial balance) --- account_financial_report/report/abstract_report_xlsx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_financial_report/report/abstract_report_xlsx.py b/account_financial_report/report/abstract_report_xlsx.py index 66a41701e75..cbd917dbe35 100644 --- a/account_financial_report/report/abstract_report_xlsx.py +++ b/account_financial_report/report/abstract_report_xlsx.py @@ -496,7 +496,7 @@ def write_ending_balance_from_dict(self, my_object, name, label, report_data): report_data["formats"]["format_header_amount"], ) elif cell_type == "amount_currency": - if my_object["currency_id"] and value: + if my_object["currency_id"]: format_amt = self._get_currency_amt_format_dict( my_object, report_data ) From 556fc41d506c55f5a6019d8755494c282f72d97d Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 16 Sep 2022 22:54:16 +0200 Subject: [PATCH 2/5] [FIX] account_financial_report: partner trial balance: sort by partner name --- account_financial_report/report/trial_balance.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/account_financial_report/report/trial_balance.py b/account_financial_report/report/trial_balance.py index 8dc4717c663..4f7ce351b51 100644 --- a/account_financial_report/report/trial_balance.py +++ b/account_financial_report/report/trial_balance.py @@ -287,6 +287,9 @@ def _compute_acc_prt_amount( total_amount[acc_id][prt_id]["ending_currency_balance"] += round( tb["amount_currency"], 2 ) + total_amount[acc_id][prt_id]["partner_name"] = ( + tb["partner_id"][1] if tb["partner_id"] else _("Missing Partner") + ) return total_amount @api.model @@ -310,6 +313,7 @@ def _compute_partner_amount( total_amount[acc_id][prt_id]["debit"] = tb["debit"] total_amount[acc_id][prt_id]["balance"] = tb["balance"] total_amount[acc_id][prt_id]["initial_balance"] = 0.0 + total_amount[acc_id][prt_id]["partner_name"] = partners_data[prt_id]["name"] partners_ids.add(prt_id) for tb in tb_initial_prt: acc_id = tb["account_id"][0] @@ -322,6 +326,15 @@ def _compute_partner_amount( total_amount = self._compute_acc_prt_amount( total_amount, tb, acc_id, prt_id, foreign_currency ) + # sort on partner_name + for acc_id, total_data in total_amount.items(): + tmp_list = sorted( + total_data.items(), + key=lambda x: isinstance(x[1], dict) and x[1]["partner_name"] or x[0], + ) + total_amount[acc_id] = {} + for key, value in tmp_list: + total_amount[acc_id][key] = value return total_amount, partners_data def _remove_accounts_at_cero(self, total_amount, show_partner_details, company): From f356445cb4c82d18c45da3c3ff31841c242f4795 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 14 Jun 2024 18:08:46 +0200 Subject: [PATCH 3/5] [FIX] account_financial_report: crash in XSLX report on partner balance --- account_financial_report/report/abstract_report_xlsx.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/account_financial_report/report/abstract_report_xlsx.py b/account_financial_report/report/abstract_report_xlsx.py index cbd917dbe35..446645d8ea4 100644 --- a/account_financial_report/report/abstract_report_xlsx.py +++ b/account_financial_report/report/abstract_report_xlsx.py @@ -597,9 +597,8 @@ def _get_currency_amt_header_format_dict(self, line_object, report_data): {"bold": True, "border": True, "bg_color": "#FFFFCC"} ) report_data["field_name"] = format_amt - format_amount = "#,##0." + ( - "0" * line_object["currency_id"].decimal_places - ) + currency = self.env["res.currency"].browse(line_object["currency_id"]) + format_amount = "#,##0." + ("0" * currency.decimal_places) format_amt.set_num_format(format_amount) return format_amt From a31dcd7a074a28c527daa26873358a8d1a617486 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 24 Oct 2024 12:27:06 +0200 Subject: [PATCH 4/5] [FIX] adapt the fix 'partner trial balance: sort by partner name' to v15 --- account_financial_report/report/trial_balance.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/account_financial_report/report/trial_balance.py b/account_financial_report/report/trial_balance.py index 4f7ce351b51..1df91a9a6fb 100644 --- a/account_financial_report/report/trial_balance.py +++ b/account_financial_report/report/trial_balance.py @@ -330,7 +330,10 @@ def _compute_partner_amount( for acc_id, total_data in total_amount.items(): tmp_list = sorted( total_data.items(), - key=lambda x: isinstance(x[1], dict) and x[1]["partner_name"] or x[0], + key=lambda x: isinstance(x[0], int) + and isinstance(x[1], dict) + and x[1]["partner_name"] + or x[0], ) total_amount[acc_id] = {} for key, value in tmp_list: From 909e4b68cde63059ac65c3ea43486c3c2a8d0c18 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 24 Oct 2024 15:34:43 +0200 Subject: [PATCH 5/5] [FIX] account_financial_report: Open Items report now sorted by account code --- account_financial_report/report/open_items.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/account_financial_report/report/open_items.py b/account_financial_report/report/open_items.py index 6dc4da6fd97..3f951c8d12a 100644 --- a/account_financial_report/report/open_items.py +++ b/account_financial_report/report/open_items.py @@ -215,11 +215,18 @@ def _calculate_amounts(self, open_items_move_lines_data): @api.model def _order_open_items_by_date( - self, open_items_move_lines_data, show_partner_details, partners_data + self, + open_items_move_lines_data, + show_partner_details, + partners_data, + accounts_data, ): + # We need to order by account code, partner_name and date + accounts_data_sorted = sorted(accounts_data.items(), key=lambda x: x[1]["code"]) + account_ids_sorted = [account[0] for account in accounts_data_sorted] new_open_items = {} if not show_partner_details: - for acc_id in open_items_move_lines_data.keys(): + for acc_id in account_ids_sorted: new_open_items[acc_id] = {} move_lines = [] for prt_id in open_items_move_lines_data[acc_id]: @@ -228,7 +235,7 @@ def _order_open_items_by_date( move_lines = sorted(move_lines, key=lambda k: (k["date"])) new_open_items[acc_id] = move_lines else: - for acc_id in open_items_move_lines_data.keys(): + for acc_id in account_ids_sorted: new_open_items[acc_id] = {} for prt_id in sorted( open_items_move_lines_data[acc_id], @@ -279,7 +286,10 @@ def _get_report_values(self, docids, data): total_amount = self._calculate_amounts(open_items_move_lines_data) open_items_move_lines_data = self._order_open_items_by_date( - open_items_move_lines_data, show_partner_details, partners_data + open_items_move_lines_data, + show_partner_details, + partners_data, + accounts_data, ) return { "doc_ids": [wizard_id],