From fb340cdab2dbf33321fc0e94a64c67199e1e1aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Sat, 17 Sep 2022 19:46:31 +0200 Subject: [PATCH] [IMP] account_financial_report: Add tax grouping in general ledger TT38721 --- .../i18n/account_financial_report.pot | 42 ++++++++- account_financial_report/i18n/es.po | 94 ++++++++++++------- .../report/general_ledger.py | 63 +++++++++++-- .../report/general_ledger_xlsx.py | 4 + .../report/templates/general_ledger.xml | 2 + .../wizard/general_ledger_wizard.py | 2 +- 6 files changed, 164 insertions(+), 43 deletions(-) diff --git a/account_financial_report/i18n/account_financial_report.pot b/account_financial_report/i18n/account_financial_report.pot index f7579c11..4523e7d2 100644 --- a/account_financial_report/i18n/account_financial_report.pot +++ b/account_financial_report/i18n/account_financial_report.pot @@ -6,6 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-09-21 15:05+0000\n" +"PO-Revision-Date: 2022-09-21 15:05+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -893,6 +895,11 @@ msgstr "" msgid "Group entries by" msgstr "" +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__grouped_by +msgid "Grouped By" +msgstr "" + #. module: account_financial_report #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/open_items_xlsx.py:0 @@ -1138,6 +1145,11 @@ msgstr "" msgid "No limit" msgstr "" +#. module: account_financial_report +#: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__none +msgid "None" +msgstr "" + #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__not_only_one_unaffected_earnings_account #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__not_only_one_unaffected_earnings_account @@ -1265,6 +1277,16 @@ msgstr "" msgid "Partner ending balance" msgstr "" +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_lines +msgid "Partner initial balance" +msgstr "" + +#. module: account_financial_report +#: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__partners +msgid "Partners" +msgstr "" + #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__payable_accounts_only #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__payable_accounts_only @@ -1400,7 +1422,6 @@ msgid "Show Move Line Details" msgstr "" #. module: account_financial_report -#: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__show_partner_details #: model:ir.model.fields,field_description:account_financial_report.field_open_items_report_wizard__show_partner_details #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__show_partner_details msgid "Show Partner Details" @@ -1514,6 +1535,12 @@ msgstr "" msgid "Tax Groups" msgstr "" +#. module: account_financial_report +#: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 +#, python-format +msgid "Tax Initial balance" +msgstr "" + #. module: account_financial_report #: code:addons/account_financial_report/report/vat_report_xlsx.py:0 #: model:ir.model.fields.selection,name:account_financial_report.selection__vat_report_wizard__based_on__taxtags @@ -1521,9 +1548,22 @@ msgstr "" msgid "Tax Tags" msgstr "" +#. module: account_financial_report +#: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 +#: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_ending_cumul +#, python-format +msgid "Tax ending balance" +msgstr "" + +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_lines +msgid "Tax initial balance" +msgstr "" + #. module: account_financial_report #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 +#: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__taxes #: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_lines #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_ledger_journal_table_header #, python-format diff --git a/account_financial_report/i18n/es.po b/account_financial_report/i18n/es.po index 1332f03c..33b0270e 100644 --- a/account_financial_report/i18n/es.po +++ b/account_financial_report/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-09-01 13:35+0000\n" -"PO-Revision-Date: 2022-09-01 15:36+0200\n" +"POT-Creation-Date: 2022-09-21 15:05+0000\n" +"PO-Revision-Date: 2022-09-21 17:07+0200\n" "Last-Translator: Pedro M. Baeza \n" "Language-Team: \n" "Language: es\n" @@ -761,7 +761,7 @@ msgstr "Número de asiento" #: code:addons/account_financial_report/static/src/xml/report.xml:0 #, python-format msgid "Export" -msgstr "" +msgstr "Exportar" #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.aged_partner_balance_wizard @@ -893,7 +893,6 @@ msgstr "Asistente de informe de Libro Mayor" #. module: account_financial_report #: model:ir.model,name:account_financial_report.model_report_a_f_r_report_general_ledger_xlsx -#, fuzzy msgid "General Ledger XLSL Report" msgstr "Libro mayor XLSX" @@ -908,12 +907,19 @@ msgid "" "General Ledger can be computed only if selected company have\n" " only one unaffected earnings account." msgstr "" +"El Libro mayor solo se puede calcular si la empresa seleccionada tiene solo " +"una cuenta de resultados no afectados." #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__group_option msgid "Group entries by" msgstr "Agrupar por" +#. module: account_financial_report +#: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__grouped_by +msgid "Grouped By" +msgstr "Agrupado por" + #. module: account_financial_report #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/open_items_xlsx.py:0 @@ -976,13 +982,12 @@ msgstr "" #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.report_trial_balance_lines_header -#, fuzzy msgid "" "Initial\n" " balance" msgstr "" "Balance\n" -" inicial moneda" +" inicial" #. module: account_financial_report #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 @@ -1013,7 +1018,7 @@ msgstr "Apunte contable" #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__domain msgid "Journal Items Domain" -msgstr "" +msgstr "Dominio Apuntes Contables" #. module: account_financial_report #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 @@ -1046,9 +1051,8 @@ msgstr "Libro diario XLSX" #. module: account_financial_report #: model:ir.model,name:account_financial_report.model_report_a_f_r_report_journal_ledger_xlsx -#, fuzzy msgid "Journal Ledger XLSX Report" -msgstr "Informe Diario de contabilidad" +msgstr "Informe Libro de diario XLSX" #. module: account_financial_report #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 @@ -1162,11 +1166,16 @@ msgstr "Sin jerarquía" msgid "No limit" msgstr "Sin límite" +#. module: account_financial_report +#: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__none +msgid "None" +msgstr "Ninguna" + #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__not_only_one_unaffected_earnings_account #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__not_only_one_unaffected_earnings_account msgid "Not Only One Unaffected Earnings Account" -msgstr "" +msgstr "No solo una cuenta de ganancias no afectadas" #. module: account_financial_report #: code:addons/account_financial_report/wizard/journal_ledger_wizard.py:0 @@ -1228,9 +1237,8 @@ msgstr "Partidas abiertas XLSX" #. module: account_financial_report #: model:ir.model,name:account_financial_report.model_report_a_f_r_report_open_items_xlsx -#, fuzzy msgid "Open Items XLSX Report" -msgstr "Partidas abiertas XLSX" +msgstr "Informe Partidas abiertas XLSX" #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.journal_ledger_wizard @@ -1288,6 +1296,16 @@ msgstr "Saldo Acumulado de Empresa" msgid "Partner ending balance" msgstr "Saldo final de empresa" +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_lines +msgid "Partner initial balance" +msgstr "Saldo inicial de empresa" + +#. module: account_financial_report +#: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__partners +msgid "Partners" +msgstr "Empresas" + #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__payable_accounts_only #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__payable_accounts_only @@ -1324,7 +1342,7 @@ msgstr "Posteado" #: code:addons/account_financial_report/static/src/xml/report.xml:0 #, python-format msgid "Print" -msgstr "" +msgstr "Imprimir" #. module: account_financial_report #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 @@ -1371,7 +1389,7 @@ msgstr "Ref - Etiqueta" #. module: account_financial_report #: model:ir.model,name:account_financial_report.model_ir_actions_report msgid "Report Action" -msgstr "" +msgstr "Acción Informe" #. module: account_financial_report #: code:addons/account_financial_report/report/aged_partner_balance_xlsx.py:0 @@ -1388,7 +1406,7 @@ msgstr "Remanente" #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_ledger_journal_table_header #, python-format msgid "Sequence" -msgstr "" +msgstr "Secuencia" #. module: account_financial_report #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 @@ -1403,19 +1421,18 @@ msgstr "Mostrar" #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__show_cost_center -#, fuzzy msgid "Show Analytic Account" -msgstr "Mostrar etiquetas analíticas" +msgstr "Mostrar cuenta analítica" #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__show_analytic_tags msgid "Show Analytic Tags" -msgstr "" +msgstr "Mostrar etiquetas analíticas" #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_journal_ledger_report_wizard__with_auto_sequence msgid "Show Auto Sequence" -msgstr "" +msgstr "Mostrar auto secuencia" #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_aged_partner_balance_report_wizard__show_move_line_details @@ -1423,7 +1440,6 @@ msgid "Show Move Line Details" msgstr "Mostrar Detalles Apuntes" #. module: account_financial_report -#: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__show_partner_details #: model:ir.model.fields,field_description:account_financial_report.field_open_items_report_wizard__show_partner_details #: model:ir.model.fields,field_description:account_financial_report.field_trial_balance_report_wizard__show_partner_details msgid "Show Partner Details" @@ -1537,6 +1553,12 @@ msgstr "Debe" msgid "Tax Groups" msgstr "Grupo de impuestos" +#. module: account_financial_report +#: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 +#, python-format +msgid "Tax Initial balance" +msgstr "Saldo inicial de impuesto" + #. module: account_financial_report #: code:addons/account_financial_report/report/vat_report_xlsx.py:0 #: model:ir.model.fields.selection,name:account_financial_report.selection__vat_report_wizard__based_on__taxtags @@ -1544,9 +1566,22 @@ msgstr "Grupo de impuestos" msgid "Tax Tags" msgstr "Etiquetas de impuestos" +#. module: account_financial_report +#: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 +#: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_ending_cumul +#, python-format +msgid "Tax ending balance" +msgstr "Saldo final de impuesto" + +#. module: account_financial_report +#: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_lines +msgid "Tax initial balance" +msgstr "Saldo inicial de impuesto" + #. module: account_financial_report #: code:addons/account_financial_report/report/general_ledger_xlsx.py:0 #: code:addons/account_financial_report/report/journal_ledger_xlsx.py:0 +#: model:ir.model.fields.selection,name:account_financial_report.selection__general_ledger_report_wizard__grouped_by__taxes #: model_terms:ir.ui.view,arch_db:account_financial_report.report_general_ledger_lines #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_ledger_journal_table_header #, python-format @@ -1592,6 +1627,8 @@ msgstr "El nivel de jerarquía a filtrar debe ser mayor que 0." #: model:ir.model.fields,help:account_financial_report.field_general_ledger_report_wizard__domain msgid "This domain will be used to select specific domain for Journal Items" msgstr "" +"Este dominio se usará para seleccionar dominios específicos para Apuntes " +"Contables" #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.report_trial_balance_filters @@ -1640,7 +1677,6 @@ msgstr "Balance de Sumas y Saldos XLSX" #. module: account_financial_report #: model:ir.model,name:account_financial_report.model_report_a_f_r_report_trial_balance_xlsx -#, fuzzy msgid "Trial Balance XLSX Report" msgstr "Balance de Sumas y Saldos XLSX" @@ -1650,6 +1686,8 @@ msgid "" "Trial Balance can be computed only if selected company have only\n" " one unaffected earnings account." msgstr "" +"El balance de sumas y saldos solo puede calcularse si la compañía " +"seleccionada tiene una y solo una cuenta de ganancias." #. module: account_financial_report #: model:ir.model.fields,field_description:account_financial_report.field_general_ledger_report_wizard__unaffected_earnings_account @@ -1705,15 +1743,13 @@ msgstr "Informe de Impuestos" #. module: account_financial_report #: model:ir.model,name:account_financial_report.model_report_account_financial_report_vat_report -#, fuzzy msgid "Vat Report Report" -msgstr "Informe de Impuestos" +msgstr "Informe de IVA" #. module: account_financial_report #: model:ir.model,name:account_financial_report.model_report_a_f_r_report_vat_report_xlsx -#, fuzzy msgid "Vat Report XLSX Report" -msgstr "Informe de impuestos XLSX" +msgstr "Informe de IVA XLSX" #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.aged_partner_balance_wizard @@ -1752,7 +1788,7 @@ msgstr "Si" #: code:addons/account_financial_report/report/general_ledger.py:0 #, python-format msgid "future" -msgstr "" +msgstr "futuro" #. module: account_financial_report #: model_terms:ir.ui.view,arch_db:account_financial_report.aged_partner_balance_wizard @@ -1803,9 +1839,3 @@ msgstr "ancho: 38.92%;" #: model_terms:ir.ui.view,arch_db:account_financial_report.report_journal_ledger_journal_table_header msgid "width: 8.11%;" msgstr "ancho: 8.11%;" - -#~ msgid "From: %s To: %s" -#~ msgstr "Desde: %s A: %s" - -#~ msgid "Not only one unaffected earnings account" -#~ msgstr "No solo una cuenta de ganancias no afectadas" diff --git a/account_financial_report/report/general_ledger.py b/account_financial_report/report/general_ledger.py index 45c980f2..8981d89f 100644 --- a/account_financial_report/report/general_ledger.py +++ b/account_financial_report/report/general_ledger.py @@ -50,16 +50,19 @@ class GeneralLedgerReport(models.AbstractModel): ) return taxes_data - def _get_acc_prt_accounts_ids(self, company_id): + def _get_account_internal_types(self, grouped_by): + return ["receivable", "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", ["receivable", "payable"]), + ("internal_type", "in", self._get_account_internal_types(grouped_by)), ] acc_prt_accounts = self.env["account.account"].search(accounts_domain) return acc_prt_accounts.ids def _get_initial_balances_bs_ml_domain( - self, account_ids, company_id, date_from, base_domain, acc_prt=False + self, account_ids, company_id, date_from, base_domain, grouped_by, acc_prt=False ): accounts_domain = [ ("company_id", "=", company_id), @@ -73,7 +76,8 @@ class GeneralLedgerReport(models.AbstractModel): accounts = self.env["account.account"].search(accounts_domain) domain += [("account_id", "in", accounts.ids)] if acc_prt: - domain += [("account_id.internal_type", "in", ["receivable", "payable"])] + internal_types = self._get_account_internal_types(grouped_by) + domain += [("account_id.internal_type", "in", internal_types)] return domain def _get_initial_balances_pl_ml_domain( @@ -147,10 +151,10 @@ class GeneralLedgerReport(models.AbstractModel): return pl_initial_balance def _get_gl_initial_acc( - self, account_ids, company_id, date_from, fy_start_date, base_domain + self, account_ids, company_id, date_from, fy_start_date, base_domain, grouped_by ): initial_domain_bs = self._get_initial_balances_bs_ml_domain( - account_ids, company_id, date_from, base_domain + account_ids, company_id, date_from, base_domain, grouped_by ) initial_domain_pl = self._get_initial_balances_pl_ml_domain( account_ids, company_id, date_from, fy_start_date, base_domain @@ -209,6 +213,36 @@ class GeneralLedgerReport(models.AbstractModel): data[acc_id][grouped_by] = True return data + def _prepare_gen_ld_data_group_taxes(self, data, domain, grouped_by): + gl_initial_acc_prt = self.env["account.move.line"].read_group( + domain=domain, + fields=[ + "account_id", + "debit", + "credit", + "balance", + "amount_currency", + "tax_line_id", + ], + groupby=["account_id"], + lazy=False, + ) + if gl_initial_acc_prt: + for gl in gl_initial_acc_prt: + if "tax_line_id" in gl and gl["tax_line_id"]: + tax_id = gl["tax_line_id"][0] + tax_name = gl["tax_line_id"][1] + tax_name = tax_name._value + else: + tax_id = 0 + tax_name = "Missing Tax" + acc_id = gl["account_id"][0] + data[acc_id][tax_id] = self._prepare_gen_ld_data_item(gl) + data[acc_id][tax_id]["id"] = tax_id + data[acc_id][tax_id]["name"] = tax_name + data[acc_id][grouped_by] = True + return data + def _get_initial_balance_data( self, account_ids, @@ -244,10 +278,10 @@ class GeneralLedgerReport(models.AbstractModel): if extra_domain: base_domain += extra_domain gl_initial_acc = self._get_gl_initial_acc( - account_ids, company_id, date_from, fy_start_date, base_domain + account_ids, company_id, date_from, fy_start_date, base_domain, grouped_by ) domain = self._get_initial_balances_bs_ml_domain( - account_ids, company_id, date_from, base_domain, acc_prt=True + account_ids, company_id, date_from, base_domain, grouped_by, acc_prt=True ) data = self._prepare_gen_ld_data(gl_initial_acc, domain, grouped_by) accounts_ids = list(data.keys()) @@ -391,6 +425,17 @@ class GeneralLedgerReport(models.AbstractModel): else "Missing Partner" ) res.append({"id": item_id, "name": item_name}) + elif grouped_by == "taxes": + if move_line["tax_line_id"]: + item_id = move_line["tax_line_id"][0] + item_name = move_line["tax_line_id"][1] + res.append({"id": item_id, "name": item_name}) + elif move_line["tax_ids"]: + for tax_id in move_line["tax_ids"]: + tax_item = self.env["account.tax"].browse(tax_id) + res.append({"id": tax_item.id, "name": tax_item.name}) + else: + res.append({"id": 0, "name": "Missing Tax"}) return res def _get_period_ml_data( @@ -449,7 +494,7 @@ class GeneralLedgerReport(models.AbstractModel): taxes_ids = set() tags_ids = set() full_reconcile_data = {} - acc_prt_account_ids = self._get_acc_prt_accounts_ids(company_id) + 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"]: diff --git a/account_financial_report/report/general_ledger_xlsx.py b/account_financial_report/report/general_ledger_xlsx.py index 2d0ac80e..bb8b8429 100644 --- a/account_financial_report/report/general_ledger_xlsx.py +++ b/account_financial_report/report/general_ledger_xlsx.py @@ -350,6 +350,8 @@ class GeneralLedgerXslx(models.AbstractModel): if "account" not in my_object["type"] and "grouped_by" in my_object: if my_object["grouped_by"] == "partners": label = _("Partner Initial balance") + elif my_object["grouped_by"] == "taxes": + label = _("Tax Initial balance") label = label if label else _("Initial balance") return super().write_initial_balance_from_dict(my_object, label, report_data) @@ -362,6 +364,8 @@ class GeneralLedgerXslx(models.AbstractModel): name = my_object["name"] if my_object["grouped_by"] == "partners": label = _("Partner ending balance") + elif my_object["grouped_by"] == "taxes": + label = _("Tax ending balance") label = label if label else _("Ending balance") return super().write_ending_balance_from_dict( my_object, name, label, report_data diff --git a/account_financial_report/report/templates/general_ledger.xml b/account_financial_report/report/templates/general_ledger.xml index 51a6583d..2b55c4d6 100644 --- a/account_financial_report/report/templates/general_ledger.xml +++ b/account_financial_report/report/templates/general_ledger.xml @@ -214,6 +214,7 @@ Initial balance Partner initial balance + Tax initial balance @@ -643,6 +644,7 @@
Partner ending balance + Tax ending balance
diff --git a/account_financial_report/wizard/general_ledger_wizard.py b/account_financial_report/wizard/general_ledger_wizard.py index 1932a7ef..0fd2598f 100644 --- a/account_financial_report/wizard/general_ledger_wizard.py +++ b/account_financial_report/wizard/general_ledger_wizard.py @@ -78,7 +78,7 @@ class GeneralLedgerReportWizard(models.TransientModel): help="Ending account in a range", ) grouped_by = fields.Selection( - selection=[("none", "None"), ("partners", "Partners")], + selection=[("none", "None"), ("partners", "Partners"), ("taxes", "Taxes")], default="partners", ) show_cost_center = fields.Boolean(