commit
1ac25220a2
|
@ -496,7 +496,7 @@ class AbstractReportXslx(models.AbstractModel):
|
||||||
report_data["formats"]["format_header_amount"],
|
report_data["formats"]["format_header_amount"],
|
||||||
)
|
)
|
||||||
elif cell_type == "amount_currency":
|
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(
|
format_amt = self._get_currency_amt_format_dict(
|
||||||
my_object, report_data
|
my_object, report_data
|
||||||
)
|
)
|
||||||
|
@ -597,9 +597,8 @@ class AbstractReportXslx(models.AbstractModel):
|
||||||
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
||||||
)
|
)
|
||||||
report_data["field_name"] = format_amt
|
report_data["field_name"] = format_amt
|
||||||
format_amount = "#,##0." + (
|
currency = self.env["res.currency"].browse(line_object["currency_id"])
|
||||||
"0" * line_object["currency_id"].decimal_places
|
format_amount = "#,##0." + ("0" * currency.decimal_places)
|
||||||
)
|
|
||||||
format_amt.set_num_format(format_amount)
|
format_amt.set_num_format(format_amount)
|
||||||
return format_amt
|
return format_amt
|
||||||
|
|
||||||
|
|
|
@ -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],
|
||||||
|
|
|
@ -287,6 +287,9 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
total_amount[acc_id][prt_id]["ending_currency_balance"] += round(
|
total_amount[acc_id][prt_id]["ending_currency_balance"] += round(
|
||||||
tb["amount_currency"], 2
|
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
|
return total_amount
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
@ -310,6 +313,7 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
total_amount[acc_id][prt_id]["debit"] = tb["debit"]
|
total_amount[acc_id][prt_id]["debit"] = tb["debit"]
|
||||||
total_amount[acc_id][prt_id]["balance"] = tb["balance"]
|
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]["initial_balance"] = 0.0
|
||||||
|
total_amount[acc_id][prt_id]["partner_name"] = partners_data[prt_id]["name"]
|
||||||
partners_ids.add(prt_id)
|
partners_ids.add(prt_id)
|
||||||
for tb in tb_initial_prt:
|
for tb in tb_initial_prt:
|
||||||
acc_id = tb["account_id"][0]
|
acc_id = tb["account_id"][0]
|
||||||
|
@ -322,6 +326,18 @@ class TrialBalanceReport(models.AbstractModel):
|
||||||
total_amount = self._compute_acc_prt_amount(
|
total_amount = self._compute_acc_prt_amount(
|
||||||
total_amount, tb, acc_id, prt_id, foreign_currency
|
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[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:
|
||||||
|
total_amount[acc_id][key] = value
|
||||||
return total_amount, partners_data
|
return total_amount, partners_data
|
||||||
|
|
||||||
def _remove_accounts_at_cero(self, total_amount, show_partner_details, company):
|
def _remove_accounts_at_cero(self, total_amount, show_partner_details, company):
|
||||||
|
|
Loading…
Reference in New Issue