[MIG] account_financial_report: Migration to 16.0

pull/1101/head
David Ramia 2022-12-20 14:25:50 +01:00 committed by Henrik Norlin
parent 36d7d32c84
commit a3cde97f8b
23 changed files with 289 additions and 318 deletions

View File

@ -6,7 +6,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Financial Reports",
"version": "15.0.2.3.0",
"version": "16.0.1.0.0",
"category": "Reporting",
"summary": "OCA Financial Reports",
"author": "Camptocamp SA,"
@ -43,14 +43,11 @@
],
"assets": {
"web.assets_backend": [
"account_financial_report/static/src/js/action_manager_report.js",
"account_financial_report/static/src/js/client_action.js",
"account_financial_report/static/src/js/report_action.esm.js",
"account_financial_report/static/src/xml/**/*",
],
"web.report_assets_common": [
"account_financial_report/static/src/js/report.js"
],
"web.assets_qweb": [
"account_financial_report/static/src/xml/**/*",
"account_financial_report/static/src/js/report.js",
],
},
"installable": True,

View File

@ -1,11 +1,29 @@
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from odoo import api, models
from odoo import api, fields, models
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
analytic_account_ids = fields.Many2many(
"account.analytic.account", compute="_compute_analytic_account_ids", store=True
)
@api.depends("analytic_distribution")
def _compute_analytic_account_ids(self):
for record in self:
if not record.analytic_distribution:
record.analytic_account_ids = False
else:
record.update(
{
"analytic_account_ids": [
(6, 0, [int(k) for k in record.analytic_distribution])
]
}
)
def init(self):
"""
The join between accounts_partners subquery and account_move_line
@ -32,9 +50,9 @@ class AccountMoveLine(models.Model):
)
@api.model
def search_count(self, args):
def search_count(self, domain, limit=None):
# In Big DataBase every time you change the domain widget this method
# takes a lot of time. This improves performance
if self.env.context.get("skip_search_count"):
return 0
return super(AccountMoveLine, self).search_count(args)
return super().search_count(domain, limit=limit)

View File

@ -13,13 +13,15 @@ class IrActionsReport(models.Model):
return dict(self.env.context or {}, lang=lang) if lang else False
@api.model
def _render_qweb_html(self, docids, data=None):
def _render_qweb_html(self, report_ref, docids, data=None):
context = self._prepare_account_financial_report_context(data)
obj = self.with_context(**context) if context else self
return super(IrActionsReport, obj)._render_qweb_html(docids, data)
return super(IrActionsReport, obj)._render_qweb_html(
report_ref, docids, data=data
)
@api.model
def _render_xlsx(self, docids, data):
def _render_xlsx(self, report_ref, docids, data=None):
context = self._prepare_account_financial_report_context(data)
obj = self.with_context(**context) if context else self
return super(IrActionsReport, obj)._render_xlsx(docids, data)
return super(IrActionsReport, obj)._render_xlsx(report_ref, docids, data=data)

View File

@ -16,12 +16,12 @@ class GeneralLedgerReport(models.AbstractModel):
_description = "General Ledger Report"
_inherit = "report.account_financial_report.abstract_report"
def _get_tags_data(self, tags_ids):
tags = self.env["account.analytic.tag"].browse(tags_ids)
tags_data = {}
for tag in tags:
tags_data.update({tag.id: {"name": tag.name}})
return tags_data
def _get_analytic_data(self, account_ids):
analytic_accounts = self.env["account.analytic.account"].browse(account_ids)
analytic_data = {}
for account in analytic_accounts:
analytic_data.update({account.id: {"name": account.name}})
return analytic_data
def _get_taxes_data(self, taxes_ids):
taxes = self.env["account.tax"].browse(taxes_ids)
@ -51,12 +51,16 @@ class GeneralLedgerReport(models.AbstractModel):
return taxes_data
def _get_account_internal_types(self, grouped_by):
return ["receivable", "payable"] if grouped_by != "taxes" else ["other"]
return (
["asset_receivable", "liability_payable"]
if grouped_by != "taxes"
else ["other"]
)
def _get_acc_prt_accounts_ids(self, company_id, grouped_by):
accounts_domain = [
("company_id", "=", company_id),
("internal_type", "in", self._get_account_internal_types(grouped_by)),
("account_type", "in", self._get_account_internal_types(grouped_by)),
]
acc_prt_accounts = self.env["account.account"].search(accounts_domain)
return acc_prt_accounts.ids
@ -66,7 +70,7 @@ class GeneralLedgerReport(models.AbstractModel):
):
accounts_domain = [
("company_id", "=", company_id),
("user_type_id.include_initial_balance", "=", True),
("include_initial_balance", "=", True),
]
if account_ids:
accounts_domain += [("id", "in", account_ids)]
@ -77,7 +81,7 @@ class GeneralLedgerReport(models.AbstractModel):
domain += [("account_id", "in", accounts.ids)]
if acc_prt:
internal_types = self._get_account_internal_types(grouped_by)
domain += [("account_id.internal_type", "in", internal_types)]
domain += [("account_type", "in", internal_types)]
return domain
def _get_initial_balances_pl_ml_domain(
@ -85,7 +89,7 @@ class GeneralLedgerReport(models.AbstractModel):
):
accounts_domain = [
("company_id", "=", company_id),
("user_type_id.include_initial_balance", "=", False),
("include_initial_balance", "=", False),
]
if account_ids:
accounts_domain += [("id", "in", account_ids)]
@ -99,12 +103,12 @@ class GeneralLedgerReport(models.AbstractModel):
def _get_accounts_initial_balance(self, initial_domain_bs, initial_domain_pl):
gl_initial_acc_bs = self.env["account.move.line"].read_group(
domain=initial_domain_bs,
fields=["account_id", "debit", "credit", "balance", "amount_currency"],
fields=["account_id", "debit", "credit", "balance", "amount_currency:sum"],
groupby=["account_id"],
)
gl_initial_acc_pl = self.env["account.move.line"].read_group(
domain=initial_domain_pl,
fields=["account_id", "debit", "credit", "balance", "amount_currency"],
fields=["account_id", "debit", "credit", "balance", "amount_currency:sum"],
groupby=["account_id"],
)
gl_initial_acc = gl_initial_acc_bs + gl_initial_acc_pl
@ -115,7 +119,7 @@ class GeneralLedgerReport(models.AbstractModel):
):
accounts_domain = [
("company_id", "=", company_id),
("user_type_id.include_initial_balance", "=", False),
("include_initial_balance", "=", False),
]
if account_ids:
accounts_domain += [("id", "in", account_ids)]
@ -134,7 +138,7 @@ class GeneralLedgerReport(models.AbstractModel):
)
initial_balances = self.env["account.move.line"].read_group(
domain=domain,
fields=["account_id", "debit", "credit", "balance", "amount_currency"],
fields=["account_id", "debit", "credit", "balance", "amount_currency:sum"],
groupby=["account_id"],
)
pl_initial_balance = {
@ -192,7 +196,7 @@ class GeneralLedgerReport(models.AbstractModel):
"debit",
"credit",
"balance",
"amount_currency",
"amount_currency:sum",
],
groupby=["account_id", "partner_id"],
lazy=False,
@ -221,7 +225,7 @@ class GeneralLedgerReport(models.AbstractModel):
"debit",
"credit",
"balance",
"amount_currency",
"amount_currency:sum",
"tax_line_id",
],
groupby=["account_id"],
@ -253,7 +257,6 @@ class GeneralLedgerReport(models.AbstractModel):
only_posted_moves,
unaffected_earnings_account,
fy_start_date,
analytic_tag_ids,
cost_center_ids,
extra_domain,
grouped_by,
@ -271,10 +274,8 @@ class GeneralLedgerReport(models.AbstractModel):
base_domain += [("move_id.state", "=", "posted")]
else:
base_domain += [("move_id.state", "in", ["posted", "draft"])]
if analytic_tag_ids:
base_domain += [("analytic_tag_ids", "in", analytic_tag_ids)]
if cost_center_ids:
base_domain += [("analytic_account_id", "in", cost_center_ids)]
base_domain += [("analytic_account_ids", "in", cost_center_ids)]
if extra_domain:
base_domain += extra_domain
gl_initial_acc = self._get_gl_initial_acc(
@ -335,14 +336,8 @@ class GeneralLedgerReport(models.AbstractModel):
"rec_name": move_line["full_reconcile_id"][1]
if move_line["full_reconcile_id"]
else "",
"tag_ids": move_line["analytic_tag_ids"],
"currency_id": move_line["currency_id"],
"analytic_account": move_line["analytic_account_id"][1]
if move_line["analytic_account_id"]
else "",
"analytic_account_id": move_line["analytic_account_id"][0]
if move_line["analytic_account_id"]
else False,
"analytic_distribution": move_line["analytic_distribution"] or {},
}
if (
move_line_data["ref"] == move_line_data["name"]
@ -365,11 +360,10 @@ class GeneralLedgerReport(models.AbstractModel):
only_posted_moves,
date_to,
date_from,
analytic_tag_ids,
cost_center_ids,
):
domain = [
("display_type", "=", False),
("display_type", "not in", ["line_note", "line_section"]),
("date", ">=", date_from),
("date", "<=", date_to),
]
@ -383,10 +377,9 @@ class GeneralLedgerReport(models.AbstractModel):
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if analytic_tag_ids:
domain += [("analytic_tag_ids", "in", analytic_tag_ids)]
if cost_center_ids:
domain += [("analytic_account_id", "in", cost_center_ids)]
domain += [("analytic_account_ids", "in", cost_center_ids)]
return domain
def _initialize_data(self, foreign_currency):
@ -450,7 +443,6 @@ class GeneralLedgerReport(models.AbstractModel):
date_from,
date_to,
gen_ld_data,
analytic_tag_ids,
cost_center_ids,
extra_domain,
grouped_by,
@ -462,7 +454,6 @@ class GeneralLedgerReport(models.AbstractModel):
only_posted_moves,
date_to,
date_from,
analytic_tag_ids,
cost_center_ids,
)
if extra_domain:
@ -482,11 +473,10 @@ class GeneralLedgerReport(models.AbstractModel):
"full_reconcile_id",
"tax_ids",
"tax_line_id",
"analytic_tag_ids",
"amount_currency",
"ref",
"name",
"analytic_account_id",
"analytic_distribution",
]
move_lines = self.env["account.move.line"].search_read(
domain=domain, fields=ml_fields
@ -494,15 +484,15 @@ class GeneralLedgerReport(models.AbstractModel):
journal_ids = set()
full_reconcile_ids = set()
taxes_ids = set()
tags_ids = set()
analytic_ids = set()
full_reconcile_data = {}
acc_prt_account_ids = self._get_acc_prt_accounts_ids(company_id, grouped_by)
for move_line in move_lines:
journal_ids.add(move_line["journal_id"][0])
for tax_id in move_line["tax_ids"]:
taxes_ids.add(tax_id)
for analytic_tag_id in move_line["analytic_tag_ids"]:
tags_ids.add(analytic_tag_id)
for analytic_account in move_line["analytic_distribution"] or {}:
analytic_ids.add(int(analytic_account))
if move_line["full_reconcile_id"]:
rec_id = move_line["full_reconcile_id"][0]
if rec_id not in full_reconcile_ids:
@ -563,7 +553,7 @@ class GeneralLedgerReport(models.AbstractModel):
journals_data = self._get_journals_data(list(journal_ids))
accounts_data = self._get_accounts_data(gen_ld_data.keys())
taxes_data = self._get_taxes_data(list(taxes_ids))
tags_data = self._get_tags_data(list(tags_ids))
analytic_data = self._get_analytic_data(list(analytic_ids))
rec_after_date_to_ids = self._get_reconciled_after_date_to_ids(
full_reconcile_data.keys(), date_to
)
@ -573,7 +563,7 @@ class GeneralLedgerReport(models.AbstractModel):
journals_data,
full_reconcile_data,
taxes_data,
tags_data,
analytic_data,
rec_after_date_to_ids,
)
@ -756,9 +746,8 @@ class GeneralLedgerReport(models.AbstractModel):
"tax_line_id": False,
"full_reconcile_id": False,
"id": False,
"tag_ids": False,
"currency_id": False,
"analytic_account_id": False,
"analytic_distribution": {},
}
)
centralized_ml[jnl_id][month]["debit"] += move_line["debit"]
@ -802,7 +791,6 @@ class GeneralLedgerReport(models.AbstractModel):
date_from = data["date_from"]
partner_ids = data["partner_ids"]
account_ids = data["account_ids"]
analytic_tag_ids = data["analytic_tag_ids"]
cost_center_ids = data["cost_center_ids"]
grouped_by = data["grouped_by"]
hide_account_at_0 = data["hide_account_at_0"]
@ -820,7 +808,6 @@ class GeneralLedgerReport(models.AbstractModel):
only_posted_moves,
unaffected_earnings_account,
fy_start_date,
analytic_tag_ids,
cost_center_ids,
extra_domain,
grouped_by,
@ -832,7 +819,7 @@ class GeneralLedgerReport(models.AbstractModel):
journals_data,
full_reconcile_data,
taxes_data,
tags_data,
analytic_data,
rec_after_date_to_ids,
) = self._get_period_ml_data(
account_ids,
@ -843,7 +830,6 @@ class GeneralLedgerReport(models.AbstractModel):
date_from,
date_to,
gen_ld_data,
analytic_tag_ids,
cost_center_ids,
extra_domain,
grouped_by,
@ -883,7 +869,6 @@ class GeneralLedgerReport(models.AbstractModel):
"date_to": data["date_to"],
"only_posted_moves": data["only_posted_moves"],
"hide_account_at_0": data["hide_account_at_0"],
"show_analytic_tags": data["show_analytic_tags"],
"show_cost_center": data["show_cost_center"],
"general_ledger": general_ledger,
"accounts_data": accounts_data,
@ -891,7 +876,7 @@ class GeneralLedgerReport(models.AbstractModel):
"full_reconcile_data": full_reconcile_data,
"taxes_data": taxes_data,
"centralize": centralize,
"tags_data": tags_data,
"analytic_data": analytic_data,
"filter_partner_ids": True if partner_ids else False,
"currency_model": self.env["res.currency"],
}

View File

@ -35,15 +35,11 @@ class GeneralLedgerXslx(models.AbstractModel):
if report.show_cost_center:
res += [
{
"header": _("Analytic Account"),
"field": "analytic_account",
"header": _("Analytic Distribution"),
"field": "analytic_distribution",
"width": 20,
},
]
if report.show_analytic_tags:
res += [
{"header": _("Tags"), "field": "tags", "width": 10},
]
res += [
{"header": _("Rec."), "field": "rec_name", "width": 15},
{
@ -113,10 +109,6 @@ class GeneralLedgerXslx(models.AbstractModel):
_("Hide") if report.hide_account_at_0 else _("Show"),
],
[_("Centralize filter"), _("Yes") if report.centralize else _("No")],
[
_("Show analytic tags"),
_("Yes") if report.show_analytic_tags else _("No"),
],
[
_("Show foreign currency"),
_("Yes") if report.foreign_currency else _("No"),
@ -147,7 +139,7 @@ class GeneralLedgerXslx(models.AbstractModel):
accounts_data = res_data["accounts_data"]
journals_data = res_data["journals_data"]
taxes_data = res_data["taxes_data"]
tags_data = res_data["tags_data"]
analytic_data = res_data["analytic_data"]
filter_partner_ids = res_data["filter_partner_ids"]
foreign_currency = res_data["foreign_currency"]
company_currency = report.company_id.currency_id
@ -196,17 +188,25 @@ class GeneralLedgerXslx(models.AbstractModel):
)
if line["ref_label"] != "Centralized entries":
taxes_description = ""
tags = ""
analytic_distribution = ""
for tax_id in line["tax_ids"]:
taxes_description += taxes_data[tax_id]["tax_name"] + " "
if line["tax_line_id"]:
taxes_description += line["tax_line_id"][1]
for tag_id in line["tag_ids"]:
tags += tags_data[tag_id]["name"] + " "
for account_id, value in line["analytic_distribution"].items():
if value < 100:
analytic_distribution += "%s %d%% " % (
analytic_data[int(account_id)]["name"],
value,
)
else:
analytic_distribution += (
"%s " % analytic_data[int(account_id)]["name"]
)
line.update(
{
"taxes_description": taxes_description,
"tags": tags,
"analytic_distribution": analytic_distribution,
}
)
if (
@ -282,17 +282,27 @@ class GeneralLedgerXslx(models.AbstractModel):
)
if line["ref_label"] != "Centralized entries":
taxes_description = ""
tags = ""
analytic_distribution = ""
for tax_id in line["tax_ids"]:
taxes_description += (
taxes_data[tax_id]["tax_name"] + " "
)
for tag_id in line["tag_ids"]:
tags += tags_data[tag_id]["name"] + " "
for account_id, value in line[
"analytic_distribution"
].items():
if value < 100:
analytic_distribution += "%s %d%% " % (
analytic_data[int(account_id)]["name"],
value,
)
else:
analytic_distribution += (
"%s " % analytic_data[int(account_id)]["name"]
)
line.update(
{
"taxes_description": taxes_description,
"tags": tags,
"analytic_distribution": analytic_distribution,
}
)
if (

View File

@ -81,7 +81,10 @@ class JournalLedgerReport(models.AbstractModel):
return moves.ids, Moves, move_data
def _get_move_lines_domain(self, move_ids, wizard, journal_ids):
return [("display_type", "=", False), ("move_id", "in", move_ids)]
return [
("display_type", "not in", ["line_note", "line_section"]),
("move_id", "in", move_ids),
]
def _get_move_lines_order(self, move_ids, wizard, journal_ids):
"""Add `move_id` to make sure the order of the records is correct
@ -134,7 +137,7 @@ class JournalLedgerReport(models.AbstractModel):
return {
"name": account.name,
"code": account.code,
"internal_type": account.internal_type,
"account_type": account.account_type,
}
def _get_partner_data(self, partners):

View File

@ -16,9 +16,9 @@
<!-- Defines global variables used by internal layout -->
<t t-set="title">
General Ledger -
<t t-raw="company_name" />
<t t-out="company_name" />
-
<t t-raw="currency_name" />
<t t-out="currency_name" />
</t>
<div class="page">
<div class="row">
@ -35,9 +35,9 @@
<!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="act_as_caption account_title" style="width: 100%">
<span t-esc="account['code']" /> - <span
t-esc="account['name']"
/>
<span t-esc="account['code']" />
-
<span t-esc="account['name']" />
</div>
<t t-if="'list_grouped' not in account">
<!-- Display account move lines without partner regroup -->
@ -109,7 +109,6 @@
<div class="act_as_cell">Target moves filter</div>
<div class="act_as_cell">Account balance at 0 filter</div>
<div class="act_as_cell">Centralize filter</div>
<div class="act_as_cell">Show analytic tags</div>
</div>
<div class="act_as_row">
<div class="act_as_cell">
@ -130,10 +129,6 @@
<t t-if="centralize">Yes</t>
<t t-if="not centralize">No</t>
</div>
<div class="act_as_cell">
<t t-if="show_analytic_tags">Yes</t>
<t t-if="not show_analytic_tags">No</t>
</div>
</div>
</div>
</template>
@ -164,7 +159,7 @@
<t t-if="show_cost_center">
<!--## cost_center-->
<div class="act_as_cell" style="width: 8.03%;">
Analytic Account
Analytic Distribution
</div>
</t>
<t t-if="show_analytic_tags">
@ -186,12 +181,11 @@
<div
class="act_as_cell amount"
style="width: 3.63%;"
>Amount cur.</div>
>Amount cur.
</div>
<!--## amount_currency cumulated-->
<div
class="act_as_cell amount"
style="width: 3.63%;"
>Cumul cur.</div>
<div class="act_as_cell amount" style="width: 3.63%;">Cumul cur.
</div>
</t>
</div>
</div>
@ -246,7 +240,7 @@
res-model="account.move.line"
>
<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}"
/>
</span>
@ -257,7 +251,7 @@
res-model="account.move.line"
>
<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}"
/>
</span>
@ -272,7 +266,7 @@
res-model="account.move.line"
>
<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}"
/>
</span>
@ -283,7 +277,7 @@
res-model="account.move.line"
>
<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}"
/>
</span>
@ -294,7 +288,7 @@
<t t-if="type == 'account_type'">
<span t-att-domain="misc_domain" res-model="account.move.line">
<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}"
/>
</span>
@ -305,7 +299,7 @@
res-model="account.move.line"
>
<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}"
/>
</span>
@ -320,7 +314,7 @@
res-model="account.move.line"
>
<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_id']}"
/>
</span>
@ -355,7 +349,7 @@
res-model="account.move.line"
>
<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_id']}"
/>
</span>
@ -409,7 +403,7 @@
res-model="account.move"
view-type="form"
>
<t t-raw="line['entry']" />
<t t-out="line['entry']" />
</span>
</t>
</div>
@ -421,7 +415,7 @@
view-type="form"
>
<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>
</div>
@ -432,7 +426,7 @@
res-model="account.account"
view-type="form"
>
<t t-raw="account['code']" />
<t t-out="account['code']" />
</span>
</div>
<!--## taxes-->
@ -456,7 +450,7 @@
res-model="res.partner"
view-type="form"
>
<t t-raw="line['partner_name']" />
<t t-out="line['partner_name']" />
</span>
</t>
</div>
@ -468,26 +462,40 @@
res-model="account.move.line"
view-type="form"
>
<t t-raw="line['ref_label']" />
<t t-out="line['ref_label']" />
</span>
</t>
<t t-else="">
<span>
<t t-raw="line['ref_label']" />
<t t-out="line['ref_label']" />
</span>
</t>
</div>
<!--## cost_center-->
<t t-if="show_cost_center">
<div class="act_as_cell left">
<t t-if="line['analytic_account_id']">
<span
t-att-res-id="line['analytic_account_id']"
res-model="account.analytic.account"
view-type="form"
>
<t t-raw="line['analytic_account']" />
</span>
<t
t-foreach="line['analytic_distribution']"
t-as="analytic_id"
>
<div>
<span
t-att-res-id="analytic_id"
res-model="account.analytic.account"
view-type="form"
>
<t
t-esc="o._get_atr_from_dict(int(analytic_id), analytic_data, 'name')"
/>
<t
t-if="int(line['analytic_distribution'][analytic_id]) &lt; 100"
>
<t
t-esc="int(line['analytic_distribution'][analytic_id])"
/>%
</t>
</span>
</div>
</t>
</div>
</t>
@ -511,7 +519,7 @@
res-model="account.full.reconcile"
view-type="form"
>
<t t-raw="line['rec_name']" />
<t t-out="line['rec_name']" />
</span>
</t>
</div>
@ -524,7 +532,7 @@
view-type="form"
>
<t
t-raw="line['debit']"
t-out="line['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -532,7 +540,7 @@
<t t-else="">
<span>
<t
t-raw="line['debit']"
t-out="line['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -547,7 +555,7 @@
view-type="form"
>
<t
t-raw="line['credit']"
t-out="line['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -555,7 +563,7 @@
<t t-else="">
<span>
<t
t-raw="line['credit']"
t-out="line['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -570,7 +578,7 @@
view-type="form"
>
<t
t-raw="line['balance']"
t-out="line['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -578,7 +586,7 @@
<t t-else="">
<span>
<t
t-raw="line['balance']"
t-out="line['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
@ -601,7 +609,7 @@
t-att-res-id="line['id']"
res-model="account.move.line"
view-type="form"
t-raw="line['bal_curr']"
t-out="line['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': line_currency}"
t-if="line_currency!=company_currency"
/>
@ -612,7 +620,7 @@
t-att-res-id="line['id']"
res-model="account.move.line"
view-type="form"
t-raw="total_bal_curr"
t-out="total_bal_curr"
t-options="{'widget': 'monetary', 'display_currency': line_currency}"
t-if="line_currency!=company_currency"
/>
@ -636,14 +644,12 @@
<!--## date-->
<t t-if='type == "account_type"'>
<div class="act_as_cell first_column" style="width: 41.32%;">
<span t-esc="account['code']" /> - <span
t-esc="account['name']"
/>
<span t-esc="account['code']" />
-
<span t-esc="account['name']" />
</div>
<div class="act_as_cell right" style="width: 16.9%;">Ending balance
</div>
<div
class="act_as_cell right"
style="width: 16.9%;"
>Ending balance</div>
</t>
<t t-if='type == "grouped_type"'>
<div class="act_as_cell first_column" style="width: 41.32%;" />
@ -706,7 +712,7 @@
style="color: black;"
>
<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_id']}"
/>
</a>
@ -753,7 +759,7 @@
style="color: black;"
>
<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_id']}"
/>
</a>

View File

@ -306,10 +306,7 @@
</t>
</div>
<div class="act_as_cell amount" name="amount_currency">
<t
t-if="move_line['amount_currency']"
t-options="{'widget': 'float', 'precision': 2}"
>
<t t-if="move_line['amount_currency']">
<span
t-esc="move_line['amount_currency']"
t-options="{'widget': 'float', 'precision': 2}"

View File

@ -25,7 +25,7 @@ class TrialBalanceReport(models.AbstractModel):
):
accounts_domain = [
("company_id", "=", company_id),
("user_type_id.include_initial_balance", "=", True),
("include_initial_balance", "=", True),
]
if account_ids:
accounts_domain += [("id", "in", account_ids)]
@ -43,7 +43,13 @@ class TrialBalanceReport(models.AbstractModel):
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if show_partner_details:
domain += [("account_id.internal_type", "in", ["receivable", "payable"])]
domain += [
(
"account_id.account_type",
"in",
["asset_receivable", "liability_payable"],
)
]
return domain
def _get_initial_balances_pl_ml_domain(
@ -59,7 +65,7 @@ class TrialBalanceReport(models.AbstractModel):
):
accounts_domain = [
("company_id", "=", company_id),
("user_type_id.include_initial_balance", "=", False),
("include_initial_balance", "=", False),
]
if account_ids:
accounts_domain += [("id", "in", account_ids)]
@ -77,7 +83,13 @@ class TrialBalanceReport(models.AbstractModel):
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if show_partner_details:
domain += [("account_id.internal_type", "in", ["receivable", "payable"])]
domain += [
(
"account_id.account_type",
"in",
["asset_receivable", "liability_payable"],
)
]
return domain
@api.model
@ -93,7 +105,7 @@ class TrialBalanceReport(models.AbstractModel):
show_partner_details,
):
domain = [
("display_type", "=", False),
("display_type", "not in", ["line_note", "line_section"]),
("date", ">=", date_from),
("date", "<=", date_to),
]
@ -110,7 +122,13 @@ class TrialBalanceReport(models.AbstractModel):
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if show_partner_details:
domain += [("account_id.internal_type", "in", ["receivable", "payable"])]
domain += [
(
"account_id.account_type",
"in",
["asset_receivable", "liability_payable"],
)
]
return domain
def _get_initial_balance_fy_pl_ml_domain(
@ -125,7 +143,7 @@ class TrialBalanceReport(models.AbstractModel):
):
accounts_domain = [
("company_id", "=", company_id),
("user_type_id.include_initial_balance", "=", False),
("include_initial_balance", "=", False),
]
if account_ids:
accounts_domain += [("id", "in", account_ids)]
@ -143,7 +161,13 @@ class TrialBalanceReport(models.AbstractModel):
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if show_partner_details:
domain += [("account_id.internal_type", "in", ["receivable", "payable"])]
domain += [
(
"account_id.account_type",
"in",
["asset_receivable", "liability_payable"],
)
]
return domain
def _get_pl_initial_balance(
@ -168,7 +192,7 @@ class TrialBalanceReport(models.AbstractModel):
)
initial_balances = self.env["account.move.line"].read_group(
domain=domain,
fields=["account_id", "balance", "amount_currency"],
fields=["account_id", "balance", "amount_currency:sum"],
groupby=["account_id"],
)
pl_initial_balance = 0.0
@ -367,7 +391,7 @@ class TrialBalanceReport(models.AbstractModel):
)
tb_initial_acc_bs = self.env["account.move.line"].read_group(
domain=initial_domain_bs,
fields=["account_id", "balance", "amount_currency"],
fields=["account_id", "balance", "amount_currency:sum"],
groupby=["account_id"],
)
initial_domain_pl = self._get_initial_balances_pl_ml_domain(
@ -382,7 +406,7 @@ class TrialBalanceReport(models.AbstractModel):
)
tb_initial_acc_pl = self.env["account.move.line"].read_group(
domain=initial_domain_pl,
fields=["account_id", "balance", "amount_currency"],
fields=["account_id", "balance", "amount_currency:sum"],
groupby=["account_id"],
)
tb_initial_acc_rg = tb_initial_acc_bs + tb_initial_acc_pl
@ -412,20 +436,20 @@ class TrialBalanceReport(models.AbstractModel):
)
tb_period_acc = self.env["account.move.line"].read_group(
domain=period_domain,
fields=["account_id", "debit", "credit", "balance", "amount_currency"],
fields=["account_id", "debit", "credit", "balance", "amount_currency:sum"],
groupby=["account_id"],
)
if show_partner_details:
tb_initial_prt_bs = self.env["account.move.line"].read_group(
domain=initial_domain_bs,
fields=["account_id", "partner_id", "balance", "amount_currency"],
fields=["account_id", "partner_id", "balance", "amount_currency:sum"],
groupby=["account_id", "partner_id"],
lazy=False,
)
tb_initial_prt_pl = self.env["account.move.line"].read_group(
domain=initial_domain_pl,
fields=["account_id", "partner_id", "balance", "amount_currency"],
fields=["account_id", "partner_id", "balance", "amount_currency:sum"],
groupby=["account_id", "partner_id"],
)
tb_initial_prt = tb_initial_prt_bs + tb_initial_prt_pl
@ -439,7 +463,7 @@ class TrialBalanceReport(models.AbstractModel):
"debit",
"credit",
"balance",
"amount_currency",
"amount_currency:sum",
],
groupby=["account_id", "partner_id"],
lazy=False,

View File

@ -66,7 +66,6 @@ class VATReport(models.AbstractModel):
"balance",
"tax_line_id",
"tax_ids",
"analytic_tag_ids",
]
tax_move_lines = self.env["account.move.line"].search_read(
domain=tax_domain,

View File

@ -1,3 +1,6 @@
a {
color: #00337b;
}
.act_as_table {
display: table !important;
background-color: white;

View File

@ -1,37 +0,0 @@
// Method is available here https://github.com/odoo/odoo/blob/15.0/addons/web/static/src/webclient/actions/action_service.js#L981
// TO DO: Check for implement this action inherit
// odoo.define("account_financial_report.ReportActionManager", function (require) {
// "use strict";
//
// const ActionManager = require("web.ActionManager");
// require("web.ReportActionManager");
//
// ActionManager.include({
// /**
// * @override
// */
// _executeReportClientAction: function (action, options) {
// const MODULE_NAME = "account_financial_report";
//
// // When 'report_action' is called from the backend, Odoo hardcodes the action tag.
// // We have to make a hack to use our own report controller.
// if (action.report_name.startsWith(`${MODULE_NAME}.`)) {
// const urls = this._makeReportUrls(action);
// const clientActionOptions = _.extend({}, options, {
// context: action.context,
// data: action.data,
// display_name: action.display_name,
// name: action.name,
// report_file: action.report_file,
// report_name: action.report_name,
// report_url: urls.html,
// });
// return this.doAction(
// "account_financial_report.client_action",
// clientActionOptions
// );
// }
// return this._super.apply(this, arguments);
// },
// });
// });

View File

@ -1,58 +0,0 @@
odoo.define("account_financial_report.client_action", function (require) {
"use strict";
var ReportAction = require("report.client_action");
var core = require("web.core");
var QWeb = core.qweb;
const AFRReportAction = ReportAction.extend({
start: function () {
return this._super.apply(this, arguments).then(() => {
this.$buttons = $(
QWeb.render(
"account_financial_report.client_action.ControlButtons",
{}
)
);
this.$buttons.on("click", ".o_report_print", this.on_click_print);
this.$buttons.on("click", ".o_report_export", this.on_click_export);
this.controlPanelProps.cp_content = {
$buttons: this.$buttons,
};
this._controlPanelWrapper.update(this.controlPanelProps);
});
},
on_click_export: function () {
const action = {
type: "ir.actions.report",
report_type: "xlsx",
report_name: this._get_xlsx_name(this.report_name),
report_file: this._get_xlsx_name(this.report_file),
data: this.data,
context: this.context,
display_name: this.title,
};
return this.do_action(action);
},
/**
* @param {String} str
* @returns {String}
*/
_get_xlsx_name: function (str) {
if (!_.isString(str)) {
return str;
}
const parts = str.split(".");
return `a_f_r.report_${parts[parts.length - 1]}_xlsx`;
},
});
core.action_registry.add("account_financial_report.client_action", AFRReportAction);
return AFRReportAction;
});

View File

@ -0,0 +1,38 @@
/** @odoo-module **/
import {ReportAction} from "@web/webclient/actions/reports/report_action";
import {patch} from "web.utils";
const MODULE_NAME = "account_financial_report";
patch(ReportAction.prototype, "account_financial_report.ReportAction", {
setup() {
this._super.apply(this, arguments);
this.isAccountFinancialReport = this.props.report_name.startsWith(
`${MODULE_NAME}.`
);
},
export() {
this.action.doAction({
type: "ir.actions.report",
report_type: "xlsx",
report_name: this._get_xlsx_name(this.props.report_name),
report_file: this._get_xlsx_name(this.props.report_file),
data: this.props.data || {},
context: this.props.context || {},
display_name: this.title,
});
},
/**
* @param {String} str
* @returns {String}
*/
_get_xlsx_name(str) {
if (!_.isString(str)) {
return str;
}
const parts = str.split(".");
return `a_f_r.report_${parts[parts.length - 1]}_xlsx`;
},
});

View File

@ -1,17 +1,19 @@
<template>
<!-- Buttons of the Control Panel -->
<t t-name="account_financial_report.client_action.ControlButtons">
<div class="o_report_buttons">
<t
t-name="info.ReportAction"
t-inherit="web.ReportAction"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//button" position="after">
<button
t-if="isAccountFinancialReport"
t-on-click="export"
type="button"
class="btn btn-primary o_report_print"
title="Print"
>Print</button>
<button
type="button"
class="btn btn-secondary o_report_export"
class="btn btn-secondary"
title="Export"
>Export</button>
</div>
</xpath>
</t>
</template>

View File

@ -28,9 +28,9 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
cls.unaffected_account = cls.env["account.account"].search(
[
(
"user_type_id",
"account_type",
"=",
cls.env.ref("account.data_unaffected_earnings").id,
"equity_unaffected",
),
("company_id", "=", cls.env.user.company_id.id),
],

View File

@ -26,9 +26,9 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
cls.account110 = cls.env["account.account"].search(
[
(
"user_type_id",
"account_type",
"=",
cls.env.ref("account.data_unaffected_earnings").id,
"equity_unaffected",
),
],
limit=1,
@ -39,9 +39,7 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
"code": "200",
"name": "Account 200",
"group_id": cls.group2.id,
"user_type_id": cls.env.ref(
"account.data_account_type_other_income"
).id,
"account_type": "income_other",
},
)
cls.account300 = cls._create_account_account(
@ -49,9 +47,7 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
{
"code": "300",
"name": "Account 300",
"user_type_id": cls.env.ref(
"account.data_account_type_other_income"
).id,
"account_type": "income_other",
},
)
cls.account301 = cls._create_account_account(
@ -60,9 +56,7 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
"code": "301",
"name": "Account 301",
"group_id": cls.group2.id,
"user_type_id": cls.env.ref(
"account.data_account_type_other_income"
).id,
"account_type": "income_other",
},
)
cls.previous_fy_date_start = "2015-01-01"
@ -75,9 +69,9 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
cls.unaffected_account = cls.env["account.account"].search(
[
(
"user_type_id",
"account_type",
"=",
cls.env.ref("account.data_unaffected_earnings").id,
"equity_unaffected",
),
],
limit=1,

View File

@ -30,7 +30,6 @@ class TestVATReport(AccountTestInvoicingCommon):
)
move_form.invoice_date = invoice_date or fields.Date.from_string("2019-01-01")
move_form.partner_id = partner or cls.partner_a
move_form.name = name or "Test"
lines = lines or []
for line in lines:
with move_form.invoice_line_ids.new() as line_form:
@ -61,9 +60,9 @@ class TestVATReport(AccountTestInvoicingCommon):
[
("company_id", "=", cls.company.id),
(
"user_type_id",
"account_type",
"=",
cls.env.ref("account.data_account_type_non_current_liabilities").id,
"liability_non_current",
),
],
limit=1,

View File

@ -101,11 +101,13 @@ class AgedPartnerBalanceWizard(models.TransientModel):
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only or self.payable_accounts_only:
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [("internal_type", "in", ("receivable", "payable"))]
domain += [
("account_type", "in", ("asset_receivable", "liability_payable"))
]
elif self.receivable_accounts_only:
domain += [("internal_type", "=", "receivable")]
domain += [("account_type", "=", "asset_receivable")]
elif self.payable_accounts_only:
domain += [("internal_type", "=", "payable")]
domain += [("account_type", "=", "liability_payable")]
self.account_ids = self.env["account.account"].search(domain)
else:
self.account_ids = None

View File

@ -43,7 +43,6 @@ class GeneralLedgerReportWizard(models.TransientModel):
"If partners are filtered, "
"debits and credits totals will not match the trial balance.",
)
show_analytic_tags = fields.Boolean()
receivable_accounts_only = fields.Boolean()
payable_accounts_only = fields.Boolean()
partner_ids = fields.Many2many(
@ -51,9 +50,6 @@ class GeneralLedgerReportWizard(models.TransientModel):
string="Filter partners",
default=lambda self: self._default_partners(),
)
analytic_tag_ids = fields.Many2many(
comodel_name="account.analytic.tag", string="Filter analytic tags"
)
account_journal_ids = fields.Many2many(
comodel_name="account.journal", string="Filter journals"
)
@ -148,10 +144,9 @@ class GeneralLedgerReportWizard(models.TransientModel):
@api.onchange("company_id")
def onchange_company_id(self):
"""Handle company change."""
account_type = self.env.ref("account.data_unaffected_earnings")
count = self.env["account.account"].search_count(
[
("user_type_id", "=", account_type.id),
("account_type", "=", "equity_unaffected"),
("company_id", "=", self.company_id.id),
]
)
@ -236,11 +231,13 @@ class GeneralLedgerReportWizard(models.TransientModel):
if self.receivable_accounts_only or self.payable_accounts_only:
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [("internal_type", "in", ("receivable", "payable"))]
domain += [
("account_type", "in", ("asset_receivable", "liability_payable"))
]
elif self.receivable_accounts_only:
domain += [("internal_type", "=", "receivable")]
domain += [("account_type", "=", "asset_receivable")]
elif self.payable_accounts_only:
domain += [("internal_type", "=", "payable")]
domain += [("account_type", "=", "liability_payable")]
self.account_ids = self.env["account.account"].search(domain)
else:
self.account_ids = None
@ -255,11 +252,10 @@ class GeneralLedgerReportWizard(models.TransientModel):
@api.depends("company_id")
def _compute_unaffected_earnings_account(self):
account_type = self.env.ref("account.data_unaffected_earnings")
for record in self:
record.unaffected_earnings_account = self.env["account.account"].search(
[
("user_type_id", "=", account_type.id),
("account_type", "=", "equity_unaffected"),
("company_id", "=", record.company_id.id),
]
)
@ -295,14 +291,12 @@ class GeneralLedgerReportWizard(models.TransientModel):
"only_posted_moves": self.target_move == "posted",
"hide_account_at_0": self.hide_account_at_0,
"foreign_currency": self.foreign_currency,
"show_analytic_tags": self.show_analytic_tags,
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids,
"grouped_by": self.grouped_by,
"cost_center_ids": self.cost_center_ids.ids,
"show_cost_center": self.show_cost_center,
"analytic_tag_ids": self.analytic_tag_ids.ids,
"journal_ids": self.account_journal_ids.ids,
"centralize": self.centralize,
"fy_start_date": self.fy_start_date,

View File

@ -29,7 +29,6 @@
<field name="centralize" />
<field name="hide_account_at_0" />
<field name="foreign_currency" />
<field name="show_analytic_tags" />
<field name="show_cost_center" />
</group>
</group>
@ -83,14 +82,6 @@
options="{'no_create': True}"
/>
</page>
<page string="Filter analytic tags">
<field
name="analytic_tag_ids"
widget="many2many_tags"
nolabel="1"
options="{'no_create': True}"
/>
</page>
<page string="Additional Filtering">
<style>
.o_domain_show_selection_button {display: none}

View File

@ -123,11 +123,13 @@ class OpenItemsReportWizard(models.TransientModel):
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only or self.payable_accounts_only:
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [("internal_type", "in", ("receivable", "payable"))]
domain += [
("account_type", "in", ("asset_receivable", "liability_payable"))
]
elif self.receivable_accounts_only:
domain += [("internal_type", "=", "receivable")]
domain += [("account_type", "=", "asset_receivable")]
elif self.payable_accounts_only:
domain += [("internal_type", "=", "payable")]
domain += [("account_type", "=", "liability_payable")]
self.account_ids = self.env["account.account"].search(domain)
else:
self.account_ids = None

View File

@ -110,10 +110,9 @@ class TrialBalanceReportWizard(models.TransientModel):
@api.onchange("company_id")
def onchange_company_id(self):
"""Handle company change."""
account_type = self.env.ref("account.data_unaffected_earnings")
count = self.env["account.account"].search_count(
[
("user_type_id", "=", account_type.id),
("account_type", "=", "equity_unaffected"),
("company_id", "=", self.company_id.id),
]
)
@ -187,11 +186,13 @@ class TrialBalanceReportWizard(models.TransientModel):
if self.receivable_accounts_only or self.payable_accounts_only:
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [("internal_type", "in", ("receivable", "payable"))]
domain += [
("account_type", "in", ("asset_receivable", "liability_payable"))
]
elif self.receivable_accounts_only:
domain += [("internal_type", "=", "receivable")]
domain += [("account_type", "=", "asset_receivable")]
elif self.payable_accounts_only:
domain += [("internal_type", "=", "payable")]
domain += [("account_type", "=", "liability_payable")]
self.account_ids = self.env["account.account"].search(domain)
else:
self.account_ids = None
@ -206,11 +207,10 @@ class TrialBalanceReportWizard(models.TransientModel):
@api.depends("company_id")
def _compute_unaffected_earnings_account(self):
account_type = self.env.ref("account.data_unaffected_earnings")
for record in self:
record.unaffected_earnings_account = self.env["account.account"].search(
[
("user_type_id", "=", account_type.id),
("account_type", "=", "equity_unaffected"),
("company_id", "=", record.company_id.id),
]
)