diff --git a/account_financial_report/__manifest__.py b/account_financial_report/__manifest__.py index 56d222be..cd63bf25 100644 --- a/account_financial_report/__manifest__.py +++ b/account_financial_report/__manifest__.py @@ -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, diff --git a/account_financial_report/models/account_move_line.py b/account_financial_report/models/account_move_line.py index dd07af0a..90b656cd 100644 --- a/account_financial_report/models/account_move_line.py +++ b/account_financial_report/models/account_move_line.py @@ -1,11 +1,29 @@ # Copyright 2019 ACSONE SA/NV () # 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) diff --git a/account_financial_report/models/ir_actions_report.py b/account_financial_report/models/ir_actions_report.py index c7e45b59..04a91396 100644 --- a/account_financial_report/models/ir_actions_report.py +++ b/account_financial_report/models/ir_actions_report.py @@ -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) diff --git a/account_financial_report/report/general_ledger.py b/account_financial_report/report/general_ledger.py index a4660072..db28e02b 100644 --- a/account_financial_report/report/general_ledger.py +++ b/account_financial_report/report/general_ledger.py @@ -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"], } diff --git a/account_financial_report/report/general_ledger_xlsx.py b/account_financial_report/report/general_ledger_xlsx.py index 2d107133..b0935e9d 100644 --- a/account_financial_report/report/general_ledger_xlsx.py +++ b/account_financial_report/report/general_ledger_xlsx.py @@ -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 ( diff --git a/account_financial_report/report/journal_ledger.py b/account_financial_report/report/journal_ledger.py index ef566de4..7ee4a9a6 100644 --- a/account_financial_report/report/journal_ledger.py +++ b/account_financial_report/report/journal_ledger.py @@ -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): diff --git a/account_financial_report/report/templates/general_ledger.xml b/account_financial_report/report/templates/general_ledger.xml index 89e2b364..b2487ef6 100644 --- a/account_financial_report/report/templates/general_ledger.xml +++ b/account_financial_report/report/templates/general_ledger.xml @@ -16,9 +16,9 @@ General Ledger - - + - - +
@@ -35,9 +35,9 @@
@@ -109,7 +109,6 @@
Target moves filter
Account balance at 0 filter
Centralize filter
-
Show analytic tags
@@ -130,10 +129,6 @@ Yes No
-
- Yes - No -
@@ -164,7 +159,7 @@
- Analytic Account + Analytic Distribution
@@ -186,12 +181,11 @@
Amount cur.
+ >Amount cur. +
-
Cumul cur.
+
Cumul cur. +
@@ -246,7 +240,7 @@ res-model="account.move.line" > @@ -257,7 +251,7 @@ res-model="account.move.line" > @@ -272,7 +266,7 @@ res-model="account.move.line" > @@ -283,7 +277,7 @@ res-model="account.move.line" > @@ -294,7 +288,7 @@ @@ -305,7 +299,7 @@ res-model="account.move.line" > @@ -320,7 +314,7 @@ res-model="account.move.line" > @@ -355,7 +349,7 @@ res-model="account.move.line" > @@ -409,7 +403,7 @@ res-model="account.move" view-type="form" > - + @@ -421,7 +415,7 @@ view-type="form" > @@ -432,7 +426,7 @@ res-model="account.account" view-type="form" > - + @@ -456,7 +450,7 @@ res-model="res.partner" view-type="form" > - + @@ -468,26 +462,40 @@ res-model="account.move.line" view-type="form" > - + - +
- - - - + +
+ + + + % + + +
@@ -511,7 +519,7 @@ res-model="account.full.reconcile" view-type="form" > - + @@ -524,7 +532,7 @@ view-type="form" > @@ -532,7 +540,7 @@ @@ -547,7 +555,7 @@ view-type="form" > @@ -555,7 +563,7 @@ @@ -570,7 +578,7 @@ view-type="form" > @@ -578,7 +586,7 @@ @@ -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 @@
- - + + - + +
+
Ending balance
-
Ending balance
@@ -706,7 +712,7 @@ style="color: black;" > @@ -753,7 +759,7 @@ style="color: black;" > diff --git a/account_financial_report/report/templates/journal_ledger.xml b/account_financial_report/report/templates/journal_ledger.xml index a2284379..17c08ebf 100644 --- a/account_financial_report/report/templates/journal_ledger.xml +++ b/account_financial_report/report/templates/journal_ledger.xml @@ -306,10 +306,7 @@
- + =", 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, diff --git a/account_financial_report/report/vat_report.py b/account_financial_report/report/vat_report.py index 7a21cbb6..4d6a8ef8 100644 --- a/account_financial_report/report/vat_report.py +++ b/account_financial_report/report/vat_report.py @@ -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, diff --git a/account_financial_report/static/src/css/report.css b/account_financial_report/static/src/css/report.css index b1764add..3a17fd72 100644 --- a/account_financial_report/static/src/css/report.css +++ b/account_financial_report/static/src/css/report.css @@ -1,3 +1,6 @@ +a { + color: #00337b; +} .act_as_table { display: table !important; background-color: white; diff --git a/account_financial_report/static/src/js/action_manager_report.js b/account_financial_report/static/src/js/action_manager_report.js deleted file mode 100644 index 380144f4..00000000 --- a/account_financial_report/static/src/js/action_manager_report.js +++ /dev/null @@ -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); -// }, -// }); -// }); diff --git a/account_financial_report/static/src/js/client_action.js b/account_financial_report/static/src/js/client_action.js deleted file mode 100644 index 57a8424b..00000000 --- a/account_financial_report/static/src/js/client_action.js +++ /dev/null @@ -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; -}); diff --git a/account_financial_report/static/src/js/report_action.esm.js b/account_financial_report/static/src/js/report_action.esm.js new file mode 100644 index 00000000..0e8e5855 --- /dev/null +++ b/account_financial_report/static/src/js/report_action.esm.js @@ -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`; + }, +}); diff --git a/account_financial_report/static/src/xml/report.xml b/account_financial_report/static/src/xml/report.xml index 1eb3a9d4..e0099355 100644 --- a/account_financial_report/static/src/xml/report.xml +++ b/account_financial_report/static/src/xml/report.xml @@ -1,17 +1,19 @@ diff --git a/account_financial_report/tests/test_general_ledger.py b/account_financial_report/tests/test_general_ledger.py index 94f51c9c..c8a2aa70 100644 --- a/account_financial_report/tests/test_general_ledger.py +++ b/account_financial_report/tests/test_general_ledger.py @@ -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), ], diff --git a/account_financial_report/tests/test_trial_balance.py b/account_financial_report/tests/test_trial_balance.py index 9d91fff9..37d713b0 100644 --- a/account_financial_report/tests/test_trial_balance.py +++ b/account_financial_report/tests/test_trial_balance.py @@ -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, diff --git a/account_financial_report/tests/test_vat_report.py b/account_financial_report/tests/test_vat_report.py index 1327cee8..91776af1 100644 --- a/account_financial_report/tests/test_vat_report.py +++ b/account_financial_report/tests/test_vat_report.py @@ -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, diff --git a/account_financial_report/wizard/aged_partner_balance_wizard.py b/account_financial_report/wizard/aged_partner_balance_wizard.py index 55ef1eba..a9be96da 100644 --- a/account_financial_report/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report/wizard/aged_partner_balance_wizard.py @@ -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 diff --git a/account_financial_report/wizard/general_ledger_wizard.py b/account_financial_report/wizard/general_ledger_wizard.py index 5eb1edf5..761bc1e8 100644 --- a/account_financial_report/wizard/general_ledger_wizard.py +++ b/account_financial_report/wizard/general_ledger_wizard.py @@ -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, diff --git a/account_financial_report/wizard/general_ledger_wizard_view.xml b/account_financial_report/wizard/general_ledger_wizard_view.xml index 08b26769..623f6c48 100644 --- a/account_financial_report/wizard/general_ledger_wizard_view.xml +++ b/account_financial_report/wizard/general_ledger_wizard_view.xml @@ -29,7 +29,6 @@ - @@ -83,14 +82,6 @@ options="{'no_create': True}" /> - - -