[FIX] account_financial_report: Open Items report now sorted by account code
parent
a31dcd7a07
commit
909e4b68cd
|
@ -215,11 +215,18 @@ class OpenItemsReport(models.AbstractModel):
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _order_open_items_by_date(
|
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 = {}
|
new_open_items = {}
|
||||||
if not show_partner_details:
|
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] = {}
|
new_open_items[acc_id] = {}
|
||||||
move_lines = []
|
move_lines = []
|
||||||
for prt_id in open_items_move_lines_data[acc_id]:
|
for prt_id in open_items_move_lines_data[acc_id]:
|
||||||
|
@ -228,7 +235,7 @@ class OpenItemsReport(models.AbstractModel):
|
||||||
move_lines = sorted(move_lines, key=lambda k: (k["date"]))
|
move_lines = sorted(move_lines, key=lambda k: (k["date"]))
|
||||||
new_open_items[acc_id] = move_lines
|
new_open_items[acc_id] = move_lines
|
||||||
else:
|
else:
|
||||||
for acc_id in open_items_move_lines_data.keys():
|
for acc_id in account_ids_sorted:
|
||||||
new_open_items[acc_id] = {}
|
new_open_items[acc_id] = {}
|
||||||
for prt_id in sorted(
|
for prt_id in sorted(
|
||||||
open_items_move_lines_data[acc_id],
|
open_items_move_lines_data[acc_id],
|
||||||
|
@ -279,7 +286,10 @@ class OpenItemsReport(models.AbstractModel):
|
||||||
|
|
||||||
total_amount = self._calculate_amounts(open_items_move_lines_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 = 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 {
|
return {
|
||||||
"doc_ids": [wizard_id],
|
"doc_ids": [wizard_id],
|
||||||
|
|
Loading…
Reference in New Issue