[IMP] account_financial_report: Add "Cumul cur." column to general_ledger.
TT38722
This commit is contained in:
committed by
chaule97
parent
0cd327f198
commit
2e678ee7b9
@@ -532,16 +532,14 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
format_amt = report_data["formats"]["format_amount"]
|
||||
field_prefix = "format_amount"
|
||||
if "currency_id" in line_object and line_object.get("currency_id", False):
|
||||
field_name = "{}_{}".format(field_prefix, line_object["currency_id"].name)
|
||||
currency = line_object["currency_id"]
|
||||
field_name = "{}_{}".format(field_prefix, currency.name)
|
||||
if hasattr(self, field_name):
|
||||
format_amt = getattr(self, field_name)
|
||||
else:
|
||||
format_amt = report_data["workbook"].add_format()
|
||||
report_data["field_name"] = format_amt
|
||||
format_amount = "#,##0." + (
|
||||
"0" * line_object["currency_id"].decimal_places
|
||||
)
|
||||
format_amt.set_num_format(format_amount)
|
||||
format_amt.set_num_format(self._report_xlsx_currency_format(currency))
|
||||
return format_amt
|
||||
|
||||
def _get_currency_amt_format_dict(self, line_dict, report_data):
|
||||
@@ -563,8 +561,7 @@ class AbstractReportXslx(models.AbstractModel):
|
||||
else:
|
||||
format_amt = report_data["workbook"].add_format()
|
||||
report_data["field_name"] = format_amt
|
||||
format_amount = "#,##0." + ("0" * currency.decimal_places)
|
||||
format_amt.set_num_format(format_amount)
|
||||
format_amt.set_num_format(self._report_xlsx_currency_format(currency))
|
||||
return format_amt
|
||||
|
||||
def _get_currency_amt_header_format(self, line_object, report_data):
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Author: Julien Coux
|
||||
# Copyright 2016 Camptocamp SA
|
||||
# Copyright 2021 Tecnativa - Jo??o Marques
|
||||
# Copyright 2022 Tecnativa - V??ctor Mart??nez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import _, models
|
||||
@@ -72,20 +73,19 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
]
|
||||
if report.foreign_currency:
|
||||
res += [
|
||||
{
|
||||
"header": _("Cur."),
|
||||
"field": "currency_name",
|
||||
"field_currency_balance": "currency_name",
|
||||
"type": "currency_name",
|
||||
"width": 7,
|
||||
},
|
||||
{
|
||||
"header": _("Amount cur."),
|
||||
"field": "bal_curr",
|
||||
"field_initial_balance": "initial_bal_curr",
|
||||
"field_final_balance": "final_bal_curr",
|
||||
"type": "amount_currency",
|
||||
"width": 14,
|
||||
"width": 10,
|
||||
},
|
||||
{
|
||||
"header": _("Cumul cur."),
|
||||
"field": "total_bal_curr",
|
||||
"type": "amount_currency",
|
||||
"width": 10,
|
||||
},
|
||||
]
|
||||
res_as_dict = {}
|
||||
@@ -149,6 +149,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
tags_data = res_data["tags_data"]
|
||||
filter_partner_ids = res_data["filter_partner_ids"]
|
||||
foreign_currency = res_data["foreign_currency"]
|
||||
company_currency = report.company_id.currency_id
|
||||
# For each account
|
||||
for account in general_ledger:
|
||||
# Write account title
|
||||
@@ -176,6 +177,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
self.write_initial_balance_from_dict(account, report_data)
|
||||
|
||||
# Display account move lines
|
||||
total_bal_curr = 0
|
||||
for line in account["move_lines"]:
|
||||
line.update(
|
||||
{
|
||||
@@ -203,6 +205,13 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
"tags": tags,
|
||||
}
|
||||
)
|
||||
if (
|
||||
foreign_currency
|
||||
and line["currency_id"]
|
||||
and line["currency_id"] != company_currency.id
|
||||
):
|
||||
total_bal_curr += line["bal_curr"]
|
||||
line.update({"total_bal_curr": total_bal_curr})
|
||||
self.write_line_from_dict(line, report_data)
|
||||
# Display ending balance line for account
|
||||
account.update(
|
||||
@@ -251,6 +260,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
self.write_initial_balance_from_dict(partner, report_data)
|
||||
|
||||
# Display account move lines
|
||||
total_bal_curr = 0
|
||||
for line in partner["move_lines"]:
|
||||
line.update(
|
||||
{
|
||||
@@ -280,6 +290,13 @@ class GeneralLedgerXslx(models.AbstractModel):
|
||||
"tags": tags,
|
||||
}
|
||||
)
|
||||
if (
|
||||
foreign_currency
|
||||
and line["currency_id"]
|
||||
and line["currency_id"] != company_currency.id
|
||||
):
|
||||
total_bal_curr += line["bal_curr"]
|
||||
line.update({"total_bal_curr": total_bal_curr})
|
||||
self.write_line_from_dict(line, report_data)
|
||||
|
||||
# Display ending balance line for partner
|
||||
|
||||
@@ -191,8 +191,13 @@
|
||||
<!--## amount_currency-->
|
||||
<div
|
||||
class="act_as_cell amount"
|
||||
style="width: 7.27%;"
|
||||
style="width: 3.63%;"
|
||||
>Amount cur.</div>
|
||||
<!--## amount_currency cumulated-->
|
||||
<div
|
||||
class="act_as_cell amount"
|
||||
style="width: 3.63%;"
|
||||
>Cumul cur.</div>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
@@ -320,7 +325,7 @@
|
||||
<t
|
||||
t-if="o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
|
||||
>
|
||||
<div class="act_as_cell amount" style="width: 7.27%;">
|
||||
<div class="act_as_cell amount" style="width: 3.63%;">
|
||||
<t t-if="type == 'account_type'">
|
||||
<t
|
||||
t-set="domain"
|
||||
@@ -355,15 +360,18 @@
|
||||
</span>
|
||||
</t>
|
||||
</div>
|
||||
<div class="act_as_cell amount" style="width: 3.63%;" />
|
||||
</t>
|
||||
<t
|
||||
t-if="not o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
|
||||
>
|
||||
<div class="act_as_cell" style="width: 7.27%;" />
|
||||
<div class="act_as_cell" style="width: 3.63%;" />
|
||||
<div class="act_as_cell" style="width: 3.63%;" />
|
||||
</t>
|
||||
</t>
|
||||
</div>
|
||||
<!-- Display each lines -->
|
||||
<t t-set="total_bal_curr" t-value="0" />
|
||||
<t t-foreach="account_or_partner_object['move_lines']" t-as="line">
|
||||
<!-- # lines or centralized lines -->
|
||||
<div class="act_as_row lines">
|
||||
@@ -576,12 +584,16 @@
|
||||
</div>
|
||||
<t t-if="foreign_currency">
|
||||
<t t-if="line['currency_id']">
|
||||
<t
|
||||
t-set="line_currency"
|
||||
t-value="currency_model.browse(line['currency_id'][0])"
|
||||
/>
|
||||
<t
|
||||
t-set="total_bal_curr"
|
||||
t-value="total_bal_curr + line['bal_curr']"
|
||||
/>
|
||||
<!--## amount_currency-->
|
||||
<div class="act_as_cell amount" style="width: 7.27%;">
|
||||
<t
|
||||
t-set="line_currency"
|
||||
t-value="currency_model.browse(line['currency_id'][0])"
|
||||
/>
|
||||
<div class="act_as_cell amount" style="width: 3.63%;">
|
||||
<span
|
||||
t-att-res-id="line['id']"
|
||||
res-model="account.move.line"
|
||||
@@ -590,10 +602,22 @@
|
||||
t-options="{'widget': 'monetary', 'display_currency': line_currency}"
|
||||
/>
|
||||
</div>
|
||||
<!--## amount_currency cumulated-->
|
||||
<div class="act_as_cell amount" style="width: 3.63%;">
|
||||
<span
|
||||
t-att-res-id="line['id']"
|
||||
res-model="account.move.line"
|
||||
view-type="form"
|
||||
t-raw="total_bal_curr"
|
||||
t-options="{'widget': 'monetary', 'display_currency': line_currency}"
|
||||
/>
|
||||
</div>
|
||||
</t>
|
||||
<t t-if="not line['currency_id']">
|
||||
<!--## amount_currency-->
|
||||
<div class="act_as_cell amount" style="width: 7.27%;" />
|
||||
<div class="act_as_cell amount" style="width: 3.63%;" />
|
||||
<!--## amount_currency cumulated-->
|
||||
<div class="act_as_cell amount" style="width: 3.63%;" />
|
||||
</t>
|
||||
</t>
|
||||
</div>
|
||||
@@ -661,7 +685,7 @@
|
||||
<t
|
||||
t-if="o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
|
||||
>
|
||||
<div class="act_as_cell amount" style="width: 7.27%;">
|
||||
<div class="act_as_cell amount" style="width: 3.63%;">
|
||||
<t t-if="type == 'account_type'">
|
||||
<t
|
||||
t-set="domain"
|
||||
@@ -704,11 +728,13 @@
|
||||
</span>
|
||||
</t>
|
||||
</div>
|
||||
<div class="act_as_cell amount" style="width: 3.63%;" />
|
||||
</t>
|
||||
<t
|
||||
t-if="not o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
|
||||
>
|
||||
<div class="act_as_cell amount" style="width: 7.27%;" />
|
||||
<div class="act_as_cell amount" style="width: 3.63%;" />
|
||||
<div class="act_as_cell amount" style="width: 3.63%;" />
|
||||
</t>
|
||||
</t>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user