From b2a8ba5edd9381263daf3d51166ba9c6aacf8ed0 Mon Sep 17 00:00:00 2001 From: Alfredo Zamora Date: Thu, 13 Jan 2022 09:02:57 +0100 Subject: [PATCH] [14.0][FIX] account_financial_report: sort based partner name in open_items report --- account_financial_report/report/open_items.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/account_financial_report/report/open_items.py b/account_financial_report/report/open_items.py index 92b2ac23..a167ba25 100644 --- a/account_financial_report/report/open_items.py +++ b/account_financial_report/report/open_items.py @@ -197,7 +197,7 @@ class OpenItemsReport(models.AbstractModel): @api.model def _order_open_items_by_date( - self, open_items_move_lines_data, show_partner_details + self, open_items_move_lines_data, show_partner_details, partners_data ): new_open_items = {} if not show_partner_details: @@ -212,7 +212,10 @@ class OpenItemsReport(models.AbstractModel): else: for acc_id in open_items_move_lines_data.keys(): new_open_items[acc_id] = {} - for prt_id in open_items_move_lines_data[acc_id]: + for prt_id in sorted( + open_items_move_lines_data[acc_id], + key=lambda i: partners_data[i]["name"], + ): new_open_items[acc_id][prt_id] = {} move_lines = [] for move_line in open_items_move_lines_data[acc_id][prt_id]: @@ -250,7 +253,7 @@ class OpenItemsReport(models.AbstractModel): 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 + open_items_move_lines_data, show_partner_details, partners_data ) return { "doc_ids": [wizard_id],