Merge PR #1236 into 15.0

Signed-off-by pedrobaeza
pull/1256/head
OCA-git-bot 2024-11-26 14:15:40 +00:00
commit fb90b3d495
3 changed files with 107 additions and 52 deletions

View File

@ -774,6 +774,7 @@ class GeneralLedgerReport(models.AbstractModel):
list_centralized_ml += list(centralized_ml[jnl_id].values()) list_centralized_ml += list(centralized_ml[jnl_id].values())
return list_centralized_ml return list_centralized_ml
# flake8: noqa: C901
def _get_report_values(self, docids, data): def _get_report_values(self, docids, data):
wizard_id = data["wizard_id"] wizard_id = data["wizard_id"]
wizard = self.env["general.ledger.report.wizard"].browse(wizard_id) wizard = self.env["general.ledger.report.wizard"].browse(wizard_id)
@ -852,6 +853,59 @@ class GeneralLedgerReport(models.AbstractModel):
account[grouped_by] = False account[grouped_by] = False
del account["list_grouped"] del account["list_grouped"]
general_ledger = sorted(general_ledger, key=lambda k: k["code"]) general_ledger = sorted(general_ledger, key=lambda k: k["code"])
# Set the bal_curr of the initial balance to 0 if it does not correspond
# (reducing the corresponding of the bal_curr of the initial balance).
for gl_item in general_ledger:
if (
not gl_item["currency_id"]
or gl_item["currency_id"] != company.currency_id
):
gl_item["fin_bal"]["bal_curr"] -= gl_item["init_bal"]["bal_curr"]
gl_item["init_bal"]["bal_curr"] = 0
if "list_grouped" in gl_item:
for lg_item in gl_item["list_grouped"]:
lg_item["fin_bal"]["bal_curr"] -= lg_item["init_bal"][
"bal_curr"
]
lg_item["init_bal"]["bal_curr"] = 0
# Set the fin_bal_currency_id value if the account does not have it set
# and there are move lines in a currency different from that of
# the company (USD for example).
for gl_item in general_ledger:
fin_bal_currency_ids = []
fin_bal_currency_id = gl_item["currency_id"]
if gl_item["currency_id"]:
continue
gl_item["fin_bal"]["bal_curr"] = gl_item["init_bal"]["bal_curr"]
if "move_lines" in gl_item:
for ml in gl_item["move_lines"]:
ml_currency_id = (
ml["currency_id"][0] if ml["currency_id"] else False
)
if ml_currency_id and ml_currency_id != company.currency_id.id:
gl_item["fin_bal"]["bal_curr"] += ml["bal_curr"]
if ml_currency_id not in fin_bal_currency_ids:
fin_bal_currency_ids.append(ml_currency_id)
elif "list_grouped" in gl_item:
fin_bal_currency_ids = []
for lg_item in gl_item["list_grouped"]:
lg_item["fin_bal"]["bal_curr"] = lg_item["init_bal"]["bal_curr"]
for ml in lg_item["move_lines"]:
ml_currency_id = (
ml["currency_id"][0] if ml["currency_id"] else False
)
if ml_currency_id and ml_currency_id != company.currency_id.id:
lg_item["fin_bal"]["bal_curr"] += ml["bal_curr"]
gl_item["fin_bal"]["bal_curr"] += ml["bal_curr"]
if ml_currency_id not in fin_bal_currency_ids:
fin_bal_currency_ids.append(ml_currency_id)
# If there is only 1 currency, we set that one as fin_bal_currency_id
# The use of different move lines with different currencies (EUR + GBP)
# will be excluded. We use a different field to avoid showing the initial
# balance and/or distorting data.
if not gl_item["currency_id"] and len(fin_bal_currency_ids) == 1:
fin_bal_currency_id = fin_bal_currency_ids[0]
gl_item["fin_bal_currency_id"] = fin_bal_currency_id
return { return {
"doc_ids": [wizard_id], "doc_ids": [wizard_id],
"doc_model": "general.ledger.report.wizard", "doc_model": "general.ledger.report.wizard",

View File

@ -347,10 +347,11 @@ class GeneralLedgerXslx(models.AbstractModel):
"final_balance": account["fin_bal"]["balance"], "final_balance": account["fin_bal"]["balance"],
} }
) )
if foreign_currency and account["currency_id"]: if foreign_currency and account["fin_bal_currency_id"]:
account.update( account.update(
{ {
"final_bal_curr": account["fin_bal"]["bal_curr"], "final_bal_curr": total_bal_curr,
"currency_id": account["fin_bal_currency_id"],
} }
) )
self.write_ending_balance_from_dict(account, report_data) self.write_ending_balance_from_dict(account, report_data)

View File

@ -16,15 +16,15 @@
<!-- Defines global variables used by internal layout --> <!-- Defines global variables used by internal layout -->
<t t-set="title"> <t t-set="title">
General Ledger - General Ledger -
<t t-raw="company_name" /> <t t-out="company_name" />
- -
<t t-raw="currency_name" /> <t t-out="currency_name" />
</t> </t>
<div class="page"> <div class="page">
<div class="row"> <div class="row">
<h4 <h4
class="mt0" class="mt0"
t-esc="title or 'Odoo Report'" t-out="title or 'Odoo Report'"
style="text-align: center;" style="text-align: center;"
/> />
</div> </div>
@ -35,8 +35,8 @@
<!-- Display account header --> <!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;" /> <div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="act_as_caption account_title" style="width: 100%"> <div class="act_as_caption account_title" style="width: 100%">
<span t-esc="account['code']" /> - <span <span t-out="account['code']" /> - <span
t-esc="account['name']" t-out="account['name']"
/> />
</div> </div>
<t t-if="'list_grouped' not in account"> <t t-if="'list_grouped' not in account">
@ -62,7 +62,7 @@
<div class="page_break"> <div class="page_break">
<!-- Display partner header --> <!-- Display partner header -->
<div class="act_as_caption account_title"> <div class="act_as_caption account_title">
<span t-esc="group_item['name']" /> <span t-out="group_item['name']" />
</div> </div>
<!-- Display partner move lines --> <!-- Display partner move lines -->
<t <t
@ -114,9 +114,9 @@
<div class="act_as_row"> <div class="act_as_row">
<div class="act_as_cell"> <div class="act_as_cell">
From: From:
<span t-esc="date_from" /> <span t-out="date_from" />
To: To:
<span t-esc="date_to" /> <span t-out="date_to" />
</div> </div>
<div class="act_as_cell"> <div class="act_as_cell">
<t t-if="only_posted_moves">All posted entries</t> <t t-if="only_posted_moves">All posted entries</t>
@ -246,7 +246,7 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_group_item_object['init_bal']['debit']" t-out="account_or_group_item_object['init_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
@ -257,7 +257,7 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_group_item_object['init_bal']['debit']" t-out="account_or_group_item_object['init_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
@ -272,7 +272,7 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_group_item_object['init_bal']['credit']" t-out="account_or_group_item_object['init_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
@ -283,7 +283,7 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_group_item_object['init_bal']['credit']" t-out="account_or_group_item_object['init_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
@ -294,7 +294,7 @@
<t t-if="type == 'account_type'"> <t t-if="type == 'account_type'">
<span t-att-domain="misc_domain" res-model="account.move.line"> <span t-att-domain="misc_domain" res-model="account.move.line">
<t <t
t-raw="account_or_group_item_object['init_bal']['balance']" t-out="account_or_group_item_object['init_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
@ -305,7 +305,7 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_group_item_object['init_bal']['balance']" t-out="account_or_group_item_object['init_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</span> </span>
@ -324,7 +324,7 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_group_item_object['init_bal']['bal_curr']" t-out="account_or_group_item_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account_currency}" t-options="{'widget': 'monetary', 'display_currency': account_currency}"
/> />
</span> </span>
@ -335,7 +335,7 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_group_item_object['init_bal']['bal_curr']" t-out="account_or_group_item_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account_currency}" t-options="{'widget': 'monetary', 'display_currency': account_currency}"
/> />
</span> </span>
@ -348,7 +348,7 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_group_item_object['init_bal']['bal_curr']" t-out="account_or_group_item_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account_currency}" t-options="{'widget': 'monetary', 'display_currency': account_currency}"
/> />
</span> </span>
@ -359,7 +359,7 @@
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
t-raw="account_or_group_item_object['init_bal']['bal_curr']" t-out="account_or_group_item_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account_currency}" t-options="{'widget': 'monetary', 'display_currency': account_currency}"
/> />
</span> </span>
@ -387,7 +387,7 @@
view-type="form" view-type="form"
> >
<t <t
t-esc="line['date']" t-out="line['date']"
t-options="{'widget': 'date'}" t-options="{'widget': 'date'}"
/> />
</span> </span>
@ -396,7 +396,7 @@
<span> <span>
<!--## We don't use t-field because it throws an error on click --> <!--## We don't use t-field because it throws an error on click -->
<t <t
t-esc="line['date']" t-out="line['date']"
t-options="{'widget': 'date'}" t-options="{'widget': 'date'}"
/> />
</span> </span>
@ -410,7 +410,7 @@
res-model="account.move" res-model="account.move"
view-type="form" view-type="form"
> >
<t t-raw="line['entry']" /> <t t-out="line['entry']" />
</span> </span>
</t> </t>
</div> </div>
@ -422,7 +422,7 @@
view-type="form" view-type="form"
> >
<t <t
t-raw="o._get_atr_from_dict(line['journal_id'], journals_data, 'code')" t-out="o._get_atr_from_dict(line['journal_id'], journals_data, 'code')"
/> />
</span> </span>
</div> </div>
@ -433,7 +433,7 @@
res-model="account.account" res-model="account.account"
view-type="form" view-type="form"
> >
<t t-raw="account['code']" /> <t t-out="account['code']" />
</span> </span>
</div> </div>
<!--## taxes--> <!--## taxes-->
@ -441,12 +441,12 @@
<t t-if="taxes_data and line['tax_ids']"> <t t-if="taxes_data and line['tax_ids']">
<t t-foreach="line['tax_ids']" t-as="tax_id"> <t t-foreach="line['tax_ids']" t-as="tax_id">
<span <span
t-esc="o._get_atr_from_dict(tax_id, taxes_data, 'tax_name')" t-out="o._get_atr_from_dict(tax_id, taxes_data, 'tax_name')"
/> />
</t> </t>
</t> </t>
<t t-if="line['tax_line_id']"> <t t-if="line['tax_line_id']">
<span t-esc="line['tax_line_id'][1]" /> <span t-out="line['tax_line_id'][1]" />
</t> </t>
</div> </div>
<!--## partner--> <!--## partner-->
@ -457,7 +457,7 @@
res-model="res.partner" res-model="res.partner"
view-type="form" view-type="form"
> >
<t t-raw="line['partner_name']" /> <t t-out="line['partner_name']" />
</span> </span>
</t> </t>
</div> </div>
@ -469,12 +469,12 @@
res-model="account.move.line" res-model="account.move.line"
view-type="form" view-type="form"
> >
<t t-raw="line['ref_label']" /> <t t-out="line['ref_label']" />
</span> </span>
</t> </t>
<t t-else=""> <t t-else="">
<span> <span>
<t t-raw="line['ref_label']" /> <t t-out="line['ref_label']" />
</span> </span>
</t> </t>
</div> </div>
@ -487,7 +487,7 @@
res-model="account.analytic.account" res-model="account.analytic.account"
view-type="form" view-type="form"
> >
<t t-raw="line['analytic_account']" /> <t t-out="line['analytic_account']" />
</span> </span>
</t> </t>
</div> </div>
@ -498,7 +498,7 @@
<t t-if="line['tag_ids']"> <t t-if="line['tag_ids']">
<t t-foreach="line['tag_ids']" t-as="tag_id"> <t t-foreach="line['tag_ids']" t-as="tag_id">
<span <span
t-esc="o._get_atr_from_dict(tag_id, tags_data, 'name')" t-out="o._get_atr_from_dict(tag_id, tags_data, 'name')"
/> />
</t> </t>
</t> </t>
@ -512,7 +512,7 @@
res-model="account.full.reconcile" res-model="account.full.reconcile"
view-type="form" view-type="form"
> >
<t t-raw="line['rec_name']" /> <t t-out="line['rec_name']" />
</span> </span>
</t> </t>
</div> </div>
@ -525,7 +525,7 @@
view-type="form" view-type="form"
> >
<t <t
t-raw="line['debit']" t-out="line['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</span> </span>
@ -533,7 +533,7 @@
<t t-else=""> <t t-else="">
<span> <span>
<t <t
t-raw="line['debit']" t-out="line['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</span> </span>
@ -548,7 +548,7 @@
view-type="form" view-type="form"
> >
<t <t
t-raw="line['credit']" t-out="line['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</span> </span>
@ -556,7 +556,7 @@
<t t-else=""> <t t-else="">
<span> <span>
<t <t
t-raw="line['credit']" t-out="line['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</span> </span>
@ -571,7 +571,7 @@
view-type="form" view-type="form"
> >
<t <t
t-raw="line['balance']" t-out="line['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</span> </span>
@ -579,7 +579,7 @@
<t t-else=""> <t t-else="">
<span> <span>
<t <t
t-raw="line['balance']" t-out="line['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</span> </span>
@ -602,7 +602,7 @@
t-att-res-id="line['id']" t-att-res-id="line['id']"
res-model="account.move.line" res-model="account.move.line"
view-type="form" view-type="form"
t-raw="line['bal_curr']" t-out="line['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': line_currency}" t-options="{'widget': 'monetary', 'display_currency': line_currency}"
t-if="line_currency!=company_currency" t-if="line_currency!=company_currency"
/> />
@ -613,7 +613,7 @@
t-att-res-id="line['id']" t-att-res-id="line['id']"
res-model="account.move.line" res-model="account.move.line"
view-type="form" view-type="form"
t-raw="total_bal_curr" t-out="total_bal_curr"
t-options="{'widget': 'monetary', 'display_currency': line_currency}" t-options="{'widget': 'monetary', 'display_currency': line_currency}"
t-if="line_currency!=company_currency" t-if="line_currency!=company_currency"
/> />
@ -637,8 +637,8 @@
<!--## date--> <!--## date-->
<t t-if='type == "account_type"'> <t t-if='type == "account_type"'>
<div class="act_as_cell first_column" style="width: 41.32%;"> <div class="act_as_cell first_column" style="width: 41.32%;">
<span t-esc="account['code']" /> - <span <span t-out="account['code']" /> - <span
t-esc="account['name']" t-out="account['name']"
/> />
</div> </div>
<div <div
@ -666,21 +666,21 @@
<!--## debit--> <!--## debit-->
<div class="act_as_cell amount" style="width: 8.02%;"> <div class="act_as_cell amount" style="width: 8.02%;">
<span <span
t-esc="account_or_group_item_object['fin_bal']['debit']" t-out="account_or_group_item_object['fin_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</div> </div>
<!--## credit--> <!--## credit-->
<div class="act_as_cell amount" style="width: 8.02%;"> <div class="act_as_cell amount" style="width: 8.02%;">
<span <span
t-esc="account_or_group_item_object['fin_bal']['credit']" t-out="account_or_group_item_object['fin_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</div> </div>
<!--## balance cumulated--> <!--## balance cumulated-->
<div class="act_as_cell amount" style="width: 8.02%;"> <div class="act_as_cell amount" style="width: 8.02%;">
<span <span
t-esc="account_or_group_item_object['fin_bal']['balance']" t-out="account_or_group_item_object['fin_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}" t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/> />
</div> </div>
@ -696,10 +696,10 @@
/> />
<t t-set="misc_grouped_domain" t-value="[]" t-else="" /> <t t-set="misc_grouped_domain" t-value="[]" t-else="" />
<t t-if="foreign_currency"> <t t-if="foreign_currency">
<t t-if="account['currency_id']"> <t t-if="account['fin_bal_currency_id']">
<t <t
t-set="account_currency" t-set="account_currency"
t-value="currency_model.browse(account['currency_id'])" t-value="currency_model.browse(account['fin_bal_currency_id'])"
/> />
<div class="act_as_cell amount" style="width: 3.63%;"> <div class="act_as_cell amount" style="width: 3.63%;">
<t t-if="type == 'account_type'"> <t t-if="type == 'account_type'">
@ -711,7 +711,7 @@
style="color: black;" style="color: black;"
> >
<t <t
t-raw="account_or_group_item_object['fin_bal']['bal_curr']" t-out="account_or_group_item_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account_currency}" t-options="{'widget': 'monetary', 'display_currency': account_currency}"
/> />
</a> </a>
@ -726,7 +726,7 @@
style="color: black;" style="color: black;"
> >
<t <t
t-raw="account_or_group_item_object['fin_bal']['bal_curr']" t-out="account_or_group_item_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account_currency}" t-options="{'widget': 'monetary', 'display_currency': account_currency}"
/> />
</a> </a>
@ -743,7 +743,7 @@
style="color: black;" style="color: black;"
> >
<t <t
t-raw="account_or_group_item_object['fin_bal']['bal_curr']" t-out="account_or_group_item_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account_currency}" t-options="{'widget': 'monetary', 'display_currency': account_currency}"
/> />
</a> </a>
@ -758,7 +758,7 @@
style="color: black;" style="color: black;"
> >
<t <t
t-raw="account_or_group_item_object['fin_bal']['bal_curr']" t-out="account_or_group_item_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account_currency}" t-options="{'widget': 'monetary', 'display_currency': account_currency}"
/> />
</a> </a>