Merge PR #918 into 15.0

Signed-off-by pedrobaeza
pull/929/head
OCA-git-bot 2022-09-21 18:08:31 +00:00
commit ff2e63d95d
8 changed files with 488 additions and 390 deletions

View File

@ -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

View File

@ -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 <pedro.baeza@gmail.com>\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"

View File

@ -1,5 +1,6 @@
# © 2016 Julien Coux (Camptocamp)
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import calendar
@ -49,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),
@ -72,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(
@ -145,6 +150,99 @@ class GeneralLedgerReport(models.AbstractModel):
pl_initial_balance["bal_curr"] += initial_balance["amount_currency"]
return pl_initial_balance
def _get_gl_initial_acc(
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, grouped_by
)
initial_domain_pl = self._get_initial_balances_pl_ml_domain(
account_ids, company_id, date_from, fy_start_date, base_domain
)
return self._get_accounts_initial_balance(initial_domain_bs, initial_domain_pl)
def _prepare_gen_ld_data_item(self, gl):
res = {}
for key_bal in ["init_bal", "fin_bal"]:
res[key_bal] = {}
for key_field in ["credit", "debit", "balance", "bal_curr"]:
field_name = key_field if key_field != "bal_curr" else "amount_currency"
res[key_bal][key_field] = gl[field_name]
return res
def _prepare_gen_ld_data(self, gl_initial_acc, domain, grouped_by):
data = {}
for gl in gl_initial_acc:
acc_id = gl["account_id"][0]
data[acc_id] = self._prepare_gen_ld_data_item(gl)
data[acc_id]["id"] = acc_id
if grouped_by:
data[acc_id][grouped_by] = False
method = "_prepare_gen_ld_data_group_%s" % grouped_by
if not hasattr(self, method):
return data
return getattr(self, method)(data, domain, grouped_by)
def _prepare_gen_ld_data_group_partners(self, data, domain, grouped_by):
gl_initial_acc_prt = self.env["account.move.line"].read_group(
domain=domain,
fields=[
"account_id",
"partner_id",
"debit",
"credit",
"balance",
"amount_currency",
],
groupby=["account_id", "partner_id"],
lazy=False,
)
if gl_initial_acc_prt:
for gl in gl_initial_acc_prt:
if not gl["partner_id"]:
prt_id = 0
prt_name = "Missing Partner"
else:
prt_id = gl["partner_id"][0]
prt_name = gl["partner_id"][1]
prt_name = prt_name._value
acc_id = gl["account_id"][0]
data[acc_id][prt_id] = self._prepare_gen_ld_data_item(gl)
data[acc_id][prt_id]["id"] = prt_id
data[acc_id][prt_id]["name"] = prt_name
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,
@ -158,6 +256,7 @@ class GeneralLedgerReport(models.AbstractModel):
analytic_tag_ids,
cost_center_ids,
extra_domain,
grouped_by,
):
# If explicit list of accounts is provided,
# don't include unaffected earnings account
@ -178,114 +277,34 @@ class GeneralLedgerReport(models.AbstractModel):
base_domain += [("analytic_account_id", "in", cost_center_ids)]
if extra_domain:
base_domain += extra_domain
initial_domain_bs = self._get_initial_balances_bs_ml_domain(
account_ids, company_id, date_from, base_domain
gl_initial_acc = self._get_gl_initial_acc(
account_ids, company_id, date_from, fy_start_date, 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
domain = self._get_initial_balances_bs_ml_domain(
account_ids, company_id, date_from, base_domain, grouped_by, acc_prt=True
)
gl_initial_acc = self._get_accounts_initial_balance(
initial_domain_bs, initial_domain_pl
)
initial_domain_acc_prt = self._get_initial_balances_bs_ml_domain(
account_ids, company_id, date_from, base_domain, acc_prt=True
)
gl_initial_acc_prt = self.env["account.move.line"].read_group(
domain=initial_domain_acc_prt,
fields=[
"account_id",
"partner_id",
"debit",
"credit",
"balance",
"amount_currency",
],
groupby=["account_id", "partner_id"],
lazy=False,
)
gen_ld_data = {}
for gl in gl_initial_acc:
acc_id = gl["account_id"][0]
gen_ld_data[acc_id] = {}
gen_ld_data[acc_id]["id"] = acc_id
gen_ld_data[acc_id]["partners"] = False
gen_ld_data[acc_id]["init_bal"] = {}
gen_ld_data[acc_id]["init_bal"]["credit"] = gl["credit"]
gen_ld_data[acc_id]["init_bal"]["debit"] = gl["debit"]
gen_ld_data[acc_id]["init_bal"]["balance"] = gl["balance"]
gen_ld_data[acc_id]["fin_bal"] = {}
gen_ld_data[acc_id]["fin_bal"]["credit"] = gl["credit"]
gen_ld_data[acc_id]["fin_bal"]["debit"] = gl["debit"]
gen_ld_data[acc_id]["fin_bal"]["balance"] = gl["balance"]
gen_ld_data[acc_id]["init_bal"]["bal_curr"] = gl["amount_currency"]
gen_ld_data[acc_id]["fin_bal"]["bal_curr"] = gl["amount_currency"]
partners_data = {}
partners_ids = set()
if gl_initial_acc_prt:
for gl in gl_initial_acc_prt:
if not gl["partner_id"]:
prt_id = 0
prt_name = "Missing Partner"
else:
prt_id = gl["partner_id"][0]
prt_name = gl["partner_id"][1]
prt_name = prt_name._value
if prt_id not in partners_ids:
partners_ids.add(prt_id)
partners_data.update({prt_id: {"id": prt_id, "name": prt_name}})
acc_id = gl["account_id"][0]
gen_ld_data[acc_id][prt_id] = {}
gen_ld_data[acc_id][prt_id]["id"] = prt_id
gen_ld_data[acc_id]["partners"] = True
gen_ld_data[acc_id][prt_id]["init_bal"] = {}
gen_ld_data[acc_id][prt_id]["init_bal"]["credit"] = gl["credit"]
gen_ld_data[acc_id][prt_id]["init_bal"]["debit"] = gl["debit"]
gen_ld_data[acc_id][prt_id]["init_bal"]["balance"] = gl["balance"]
gen_ld_data[acc_id][prt_id]["fin_bal"] = {}
gen_ld_data[acc_id][prt_id]["fin_bal"]["credit"] = gl["credit"]
gen_ld_data[acc_id][prt_id]["fin_bal"]["debit"] = gl["debit"]
gen_ld_data[acc_id][prt_id]["fin_bal"]["balance"] = gl["balance"]
gen_ld_data[acc_id][prt_id]["init_bal"]["bal_curr"] = gl[
"amount_currency"
]
gen_ld_data[acc_id][prt_id]["fin_bal"]["bal_curr"] = gl[
"amount_currency"
]
accounts_ids = list(gen_ld_data.keys())
data = self._prepare_gen_ld_data(gl_initial_acc, domain, grouped_by)
accounts_ids = list(data.keys())
unaffected_id = unaffected_earnings_account
if unaffected_id:
if unaffected_id not in accounts_ids:
accounts_ids.append(unaffected_id)
self._initialize_account(gen_ld_data, unaffected_id, foreign_currency)
data[unaffected_id] = self._initialize_data(foreign_currency)
data[unaffected_id]["id"] = unaffected_id
data[unaffected_id]["mame"] = ""
data[unaffected_id][grouped_by] = False
pl_initial_balance = self._get_pl_initial_balance(
account_ids, company_id, fy_start_date, foreign_currency, base_domain
)
gen_ld_data[unaffected_id]["init_bal"]["debit"] += pl_initial_balance[
"debit"
]
gen_ld_data[unaffected_id]["init_bal"]["credit"] += pl_initial_balance[
"credit"
]
gen_ld_data[unaffected_id]["init_bal"]["balance"] += pl_initial_balance[
"balance"
]
gen_ld_data[unaffected_id]["fin_bal"]["debit"] += pl_initial_balance[
"debit"
]
gen_ld_data[unaffected_id]["fin_bal"]["credit"] += pl_initial_balance[
"credit"
]
gen_ld_data[unaffected_id]["fin_bal"]["balance"] += pl_initial_balance[
"balance"
]
if foreign_currency:
gen_ld_data[unaffected_id]["init_bal"][
"bal_curr"
] += pl_initial_balance["bal_curr"]
gen_ld_data[unaffected_id]["fin_bal"]["bal_curr"] += pl_initial_balance[
"bal_curr"
]
return gen_ld_data, partners_data, partner_ids
for key_bal in ["init_bal", "fin_bal"]:
fields_balance = ["credit", "debit", "balance"]
if foreign_currency:
fields_balance.append("bal_curr")
for field_name in fields_balance:
data[unaffected_id][key_bal][field_name] += pl_initial_balance[
field_name
]
return data
@api.model
def _get_move_line_data(self, move_line):
@ -305,6 +324,7 @@ class GeneralLedgerReport(models.AbstractModel):
"ref": "" if not move_line["ref"] else move_line["ref"],
"name": "" if not move_line["name"] else move_line["name"],
"tax_ids": move_line["tax_ids"],
"tax_line_id": move_line["tax_line_id"],
"debit": move_line["debit"],
"credit": move_line["credit"],
"balance": move_line["balance"],
@ -369,40 +389,15 @@ class GeneralLedgerReport(models.AbstractModel):
domain += [("analytic_account_id", "in", cost_center_ids)]
return domain
@api.model
def _initialize_partner(self, gen_ld_data, acc_id, prt_id, foreign_currency):
gen_ld_data[acc_id]["partners"] = True
gen_ld_data[acc_id][prt_id] = {}
gen_ld_data[acc_id][prt_id]["id"] = prt_id
gen_ld_data[acc_id][prt_id]["init_bal"] = {}
gen_ld_data[acc_id][prt_id]["init_bal"]["balance"] = 0.0
gen_ld_data[acc_id][prt_id]["init_bal"]["credit"] = 0.0
gen_ld_data[acc_id][prt_id]["init_bal"]["debit"] = 0.0
gen_ld_data[acc_id][prt_id]["fin_bal"] = {}
gen_ld_data[acc_id][prt_id]["fin_bal"]["credit"] = 0.0
gen_ld_data[acc_id][prt_id]["fin_bal"]["debit"] = 0.0
gen_ld_data[acc_id][prt_id]["fin_bal"]["balance"] = 0.0
if foreign_currency:
gen_ld_data[acc_id][prt_id]["init_bal"]["bal_curr"] = 0.0
gen_ld_data[acc_id][prt_id]["fin_bal"]["bal_curr"] = 0.0
return gen_ld_data
def _initialize_account(self, gen_ld_data, acc_id, foreign_currency):
gen_ld_data[acc_id] = {}
gen_ld_data[acc_id]["id"] = acc_id
gen_ld_data[acc_id]["partners"] = False
gen_ld_data[acc_id]["init_bal"] = {}
gen_ld_data[acc_id]["init_bal"]["balance"] = 0.0
gen_ld_data[acc_id]["init_bal"]["credit"] = 0.0
gen_ld_data[acc_id]["init_bal"]["debit"] = 0.0
gen_ld_data[acc_id]["fin_bal"] = {}
gen_ld_data[acc_id]["fin_bal"]["credit"] = 0.0
gen_ld_data[acc_id]["fin_bal"]["debit"] = 0.0
gen_ld_data[acc_id]["fin_bal"]["balance"] = 0.0
if foreign_currency:
gen_ld_data[acc_id]["init_bal"]["bal_curr"] = 0.0
gen_ld_data[acc_id]["fin_bal"]["bal_curr"] = 0.0
return gen_ld_data
def _initialize_data(self, foreign_currency):
res = {}
for key_bal in ["init_bal", "fin_bal"]:
res[key_bal] = {}
for key_field in ["balance", "credit", "debit"]:
res[key_bal][key_field] = 0.0
if foreign_currency:
res[key_bal]["bal_curr"] = 0.0
return res
def _get_reconciled_after_date_to_ids(self, full_reconcile_ids, date_to):
full_reconcile_ids = list(full_reconcile_ids)
@ -420,6 +415,29 @@ class GeneralLedgerReport(models.AbstractModel):
rec_after_date_to_ids = [i[0] for i in rec_after_date_to_ids]
return rec_after_date_to_ids
def _prepare_ml_items(self, move_line, grouped_by):
res = []
if grouped_by == "partners":
item_id = move_line["partner_id"][0] if move_line["partner_id"] else 0
item_name = (
move_line["partner_id"][1]
if move_line["partner_id"]
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(
self,
account_ids,
@ -429,12 +447,11 @@ class GeneralLedgerReport(models.AbstractModel):
only_posted_moves,
date_from,
date_to,
partners_data,
gen_ld_data,
partners_ids,
analytic_tag_ids,
cost_center_ids,
extra_domain,
grouped_by,
):
domain = self._get_period_domain(
account_ids,
@ -462,6 +479,7 @@ class GeneralLedgerReport(models.AbstractModel):
"currency_id",
"full_reconcile_id",
"tax_ids",
"tax_line_id",
"analytic_tag_ids",
"amount_currency",
"ref",
@ -476,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"]:
@ -497,33 +515,38 @@ class GeneralLedgerReport(models.AbstractModel):
full_reconcile_ids.add(rec_id)
acc_id = move_line["account_id"][0]
ml_id = move_line["id"]
if move_line["partner_id"]:
prt_id = move_line["partner_id"][0]
partner_name = move_line["partner_id"][1]
if acc_id not in gen_ld_data.keys():
gen_ld_data = self._initialize_account(
gen_ld_data, acc_id, foreign_currency
)
gen_ld_data[acc_id] = self._initialize_data(foreign_currency)
gen_ld_data[acc_id]["id"] = acc_id
gen_ld_data[acc_id]["mame"] = move_line["account_id"][1]
gen_ld_data[acc_id][grouped_by] = False
if acc_id in acc_prt_account_ids:
if not move_line["partner_id"]:
prt_id = 0
partner_name = "Missing Partner"
partners_ids.append(prt_id)
partners_data.update({prt_id: {"id": prt_id, "name": partner_name}})
if prt_id not in gen_ld_data[acc_id]:
gen_ld_data = self._initialize_partner(
gen_ld_data, acc_id, prt_id, foreign_currency
item_ids = self._prepare_ml_items(move_line, grouped_by)
for item in item_ids:
item_id = item["id"]
if item_id not in gen_ld_data[acc_id]:
gen_ld_data[acc_id][grouped_by] = True
gen_ld_data[acc_id][item_id] = self._initialize_data(
foreign_currency
)
gen_ld_data[acc_id][item_id]["id"] = item_id
gen_ld_data[acc_id][item_id]["name"] = item["name"]
gen_ld_data[acc_id][item_id][ml_id] = self._get_move_line_data(
move_line
)
gen_ld_data[acc_id][prt_id][ml_id] = self._get_move_line_data(move_line)
gen_ld_data[acc_id][prt_id]["fin_bal"]["credit"] += move_line["credit"]
gen_ld_data[acc_id][prt_id]["fin_bal"]["debit"] += move_line["debit"]
gen_ld_data[acc_id][prt_id]["fin_bal"]["balance"] += move_line[
"balance"
]
if foreign_currency:
gen_ld_data[acc_id][prt_id]["fin_bal"]["bal_curr"] += move_line[
"amount_currency"
gen_ld_data[acc_id][item_id]["fin_bal"]["credit"] += move_line[
"credit"
]
gen_ld_data[acc_id][item_id]["fin_bal"]["debit"] += move_line[
"debit"
]
gen_ld_data[acc_id][item_id]["fin_bal"]["balance"] += move_line[
"balance"
]
if foreign_currency:
gen_ld_data[acc_id][item_id]["fin_bal"][
"bal_curr"
] += move_line["amount_currency"]
else:
gen_ld_data[acc_id][ml_id] = self._get_move_line_data(move_line)
gen_ld_data[acc_id]["fin_bal"]["credit"] += move_line["credit"]
@ -543,7 +566,6 @@ class GeneralLedgerReport(models.AbstractModel):
return (
gen_ld_data,
accounts_data,
partners_data,
journals_data,
full_reconcile_data,
taxes_data,
@ -578,14 +600,14 @@ class GeneralLedgerReport(models.AbstractModel):
account.update({"move_lines": move_lines})
return account
def _create_account_not_show_partner(
self, account, acc_id, gen_led_data, rec_after_date_to_ids
def _create_account_not_show_item(
self, account, acc_id, gen_led_data, rec_after_date_to_ids, grouped_by
):
move_lines = []
for prt_id in gen_led_data[acc_id].keys():
if not isinstance(prt_id, int):
account.update({prt_id: gen_led_data[acc_id][prt_id]})
else:
elif isinstance(gen_led_data[acc_id][prt_id], dict):
for ml_id in gen_led_data[acc_id][prt_id].keys():
if isinstance(ml_id, int):
move_lines += [gen_led_data[acc_id][prt_id][ml_id]]
@ -595,14 +617,48 @@ class GeneralLedgerReport(models.AbstractModel):
gen_led_data[acc_id]["init_bal"]["balance"],
rec_after_date_to_ids,
)
account.update({"move_lines": move_lines, "partners": False})
account.update({"move_lines": move_lines, grouped_by: False})
return account
def _get_list_grouped_item(
self, data, account, rec_after_date_to_ids, hide_account_at_0, rounding
):
list_grouped = []
for data_id in data.keys():
group_item = {}
move_lines = []
if not isinstance(data_id, int):
account.update({data_id: data[data_id]})
else:
for ml_id in data[data_id].keys():
if not isinstance(ml_id, int):
group_item.update({ml_id: data[data_id][ml_id]})
else:
move_lines += [data[data_id][ml_id]]
move_lines = sorted(move_lines, key=lambda k: (k["date"]))
move_lines = self._recalculate_cumul_balance(
move_lines,
data[data_id]["init_bal"]["balance"],
rec_after_date_to_ids,
)
group_item.update({"move_lines": move_lines})
if (
hide_account_at_0
and float_is_zero(
data[data_id]["init_bal"]["balance"],
precision_rounding=rounding,
)
and group_item["move_lines"] == []
):
continue
list_grouped += [group_item]
return account, list_grouped
def _create_general_ledger(
self,
gen_led_data,
accounts_data,
show_partner_details,
grouped_by,
rec_after_date_to_ids,
hide_account_at_0,
):
@ -617,9 +673,10 @@ class GeneralLedgerReport(models.AbstractModel):
"type": "account",
"currency_id": accounts_data[acc_id]["currency_id"],
"centralized": accounts_data[acc_id]["centralized"],
"grouped_by": grouped_by,
}
)
if not gen_led_data[acc_id]["partners"]:
if grouped_by and not gen_led_data[acc_id][grouped_by]:
account = self._create_account(
account, acc_id, gen_led_data, rec_after_date_to_ids
)
@ -633,51 +690,27 @@ class GeneralLedgerReport(models.AbstractModel):
):
continue
else:
if show_partner_details:
list_partner = []
for prt_id in gen_led_data[acc_id].keys():
partner = {}
move_lines = []
if not isinstance(prt_id, int):
account.update({prt_id: gen_led_data[acc_id][prt_id]})
else:
for ml_id in gen_led_data[acc_id][prt_id].keys():
if not isinstance(ml_id, int):
partner.update(
{ml_id: gen_led_data[acc_id][prt_id][ml_id]}
)
else:
move_lines += [gen_led_data[acc_id][prt_id][ml_id]]
move_lines = sorted(move_lines, key=lambda k: (k["date"]))
move_lines = self._recalculate_cumul_balance(
move_lines,
gen_led_data[acc_id][prt_id]["init_bal"]["balance"],
rec_after_date_to_ids,
)
partner.update({"move_lines": move_lines})
if (
hide_account_at_0
and float_is_zero(
gen_led_data[acc_id][prt_id]["init_bal"]["balance"],
precision_rounding=rounding,
)
and partner["move_lines"] == []
):
continue
list_partner += [partner]
account.update({"list_partner": list_partner})
if grouped_by:
account, list_grouped = self._get_list_grouped_item(
gen_led_data[acc_id],
account,
rec_after_date_to_ids,
hide_account_at_0,
rounding,
)
account.update({"list_grouped": list_grouped})
if (
hide_account_at_0
and float_is_zero(
gen_led_data[acc_id]["init_bal"]["balance"],
precision_rounding=rounding,
)
and account["list_partner"] == []
and account["list_grouped"] == []
):
continue
else:
account = self._create_account_not_show_partner(
account, acc_id, gen_led_data, rec_after_date_to_ids
account = self._create_account_not_show_item(
account, acc_id, gen_led_data, rec_after_date_to_ids, grouped_by
)
if (
hide_account_at_0
@ -716,6 +749,7 @@ class GeneralLedgerReport(models.AbstractModel):
"rec_id": 0,
"entry_id": False,
"tax_ids": [],
"tax_line_id": False,
"full_reconcile_id": False,
"id": False,
"tag_ids": False,
@ -732,13 +766,13 @@ class GeneralLedgerReport(models.AbstractModel):
return centralized_ml
@api.model
def _get_centralized_ml(self, account, date_to):
def _get_centralized_ml(self, account, date_to, grouped_by):
centralized_ml = {}
if isinstance(date_to, str):
date_to = datetime.datetime.strptime(date_to, "%Y-%m-%d").date()
if account["partners"]:
for partner in account["list_partner"]:
for move_line in partner["move_lines"]:
if grouped_by and account[grouped_by]:
for item in account["list_grouped"]:
for move_line in item["move_lines"]:
centralized_ml = self._calculate_centralization(
centralized_ml,
move_line,
@ -763,21 +797,17 @@ class GeneralLedgerReport(models.AbstractModel):
date_to = data["date_to"]
date_from = data["date_from"]
partner_ids = data["partner_ids"]
if not partner_ids:
filter_partner_ids = False
else:
filter_partner_ids = True
account_ids = data["account_ids"]
analytic_tag_ids = data["analytic_tag_ids"]
cost_center_ids = data["cost_center_ids"]
show_partner_details = data["show_partner_details"]
grouped_by = data["grouped_by"]
hide_account_at_0 = data["hide_account_at_0"]
foreign_currency = data["foreign_currency"]
only_posted_moves = data["only_posted_moves"]
unaffected_earnings_account = data["unaffected_earnings_account"]
fy_start_date = data["fy_start_date"]
extra_domain = data["domain"]
gen_ld_data, partners_data, partners_ids = self._get_initial_balance_data(
gen_ld_data = self._get_initial_balance_data(
account_ids,
partner_ids,
company_id,
@ -789,12 +819,12 @@ class GeneralLedgerReport(models.AbstractModel):
analytic_tag_ids,
cost_center_ids,
extra_domain,
grouped_by,
)
centralize = data["centralize"]
(
gen_ld_data,
accounts_data,
partners_data,
journals_data,
full_reconcile_data,
taxes_data,
@ -808,33 +838,34 @@ class GeneralLedgerReport(models.AbstractModel):
only_posted_moves,
date_from,
date_to,
partners_data,
gen_ld_data,
partners_ids,
analytic_tag_ids,
cost_center_ids,
extra_domain,
grouped_by,
)
general_ledger = self._create_general_ledger(
gen_ld_data,
accounts_data,
show_partner_details,
grouped_by,
rec_after_date_to_ids,
hide_account_at_0,
)
if centralize:
for account in general_ledger:
if account["centralized"]:
centralized_ml = self._get_centralized_ml(account, date_to)
centralized_ml = self._get_centralized_ml(
account, date_to, grouped_by
)
account["move_lines"] = centralized_ml
account["move_lines"] = self._recalculate_cumul_balance(
account["move_lines"],
gen_ld_data[account["id"]]["init_bal"]["balance"],
rec_after_date_to_ids,
)
if account["partners"]:
account["partners"] = False
del account["list_partner"]
if grouped_by and account[grouped_by]:
account[grouped_by] = False
del account["list_grouped"]
general_ledger = sorted(general_ledger, key=lambda k: k["code"])
return {
"doc_ids": [wizard_id],
@ -852,12 +883,11 @@ class GeneralLedgerReport(models.AbstractModel):
"show_cost_center": data["show_cost_center"],
"general_ledger": general_ledger,
"accounts_data": accounts_data,
"partners_data": partners_data,
"journals_data": journals_data,
"full_reconcile_data": full_reconcile_data,
"taxes_data": taxes_data,
"centralize": centralize,
"tags_data": tags_data,
"filter_partner_ids": filter_partner_ids,
"filter_partner_ids": True if partner_ids else False,
"currency_model": self.env["res.currency"],
}

View File

@ -143,7 +143,6 @@ class GeneralLedgerXslx(models.AbstractModel):
]._get_report_values(report, data)
general_ledger = res_data["general_ledger"]
accounts_data = res_data["accounts_data"]
partners_data = res_data["partners_data"]
journals_data = res_data["journals_data"]
taxes_data = res_data["taxes_data"]
tags_data = res_data["tags_data"]
@ -158,7 +157,7 @@ class GeneralLedgerXslx(models.AbstractModel):
report_data,
)
if not account["partners"]:
if "list_grouped" not in account:
# Display array header for move lines
self.write_array_header(report_data)
@ -198,6 +197,8 @@ class GeneralLedgerXslx(models.AbstractModel):
tags = ""
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"] + " "
line.update(
@ -232,37 +233,37 @@ class GeneralLedgerXslx(models.AbstractModel):
else:
# For each partner
for partner in account["list_partner"]:
for group_item in account["list_grouped"]:
# Write partner title
self.write_array_title(
partners_data[partner["id"]]["name"], report_data
)
self.write_array_title(group_item["name"], report_data)
# Display array header for move lines
self.write_array_header(report_data)
# Display initial balance line for partner
partner.update(
group_item.update(
{
"initial_debit": partner["init_bal"]["debit"],
"initial_credit": partner["init_bal"]["credit"],
"initial_balance": partner["init_bal"]["balance"],
"name": partners_data[partner["id"]]["name"],
"initial_debit": group_item["init_bal"]["debit"],
"initial_credit": group_item["init_bal"]["credit"],
"initial_balance": group_item["init_bal"]["balance"],
"type": "partner",
"grouped_by": account["grouped_by"]
if "grouped_by" in account
else "",
"currency_id": accounts_data[account["id"]]["currency_id"],
}
)
if foreign_currency:
partner.update(
group_item.update(
{
"initial_bal_curr": partner["init_bal"]["bal_curr"],
"initial_bal_curr": group_item["init_bal"]["bal_curr"],
}
)
self.write_initial_balance_from_dict(partner, report_data)
self.write_initial_balance_from_dict(group_item, report_data)
# Display account move lines
total_bal_curr = 0
for line in partner["move_lines"]:
for line in group_item["move_lines"]:
line.update(
{
"account": account["code"],
@ -302,22 +303,22 @@ class GeneralLedgerXslx(models.AbstractModel):
self.write_line_from_dict(line, report_data)
# Display ending balance line for partner
partner.update(
group_item.update(
{
"final_debit": partner["fin_bal"]["debit"],
"final_credit": partner["fin_bal"]["credit"],
"final_balance": partner["fin_bal"]["balance"],
"final_debit": group_item["fin_bal"]["debit"],
"final_credit": group_item["fin_bal"]["credit"],
"final_balance": group_item["fin_bal"]["balance"],
}
)
if foreign_currency and partner["currency_id"]:
partner.update(
if foreign_currency and group_item["currency_id"]:
group_item.update(
{
"final_bal_curr": partner["fin_bal"]["bal_curr"],
"currency_name": partner["currency_id"].name,
"currency_id": partner["currency_id"].id,
"final_bal_curr": group_item["fin_bal"]["bal_curr"],
"currency_name": group_item["currency_id"].name,
"currency_id": group_item["currency_id"].id,
}
)
self.write_ending_balance_from_dict(partner, report_data)
self.write_ending_balance_from_dict(group_item, report_data)
# Line break
report_data["row_pos"] += 1
@ -345,22 +346,27 @@ class GeneralLedgerXslx(models.AbstractModel):
def write_initial_balance_from_dict(self, my_object, report_data):
"""Specific function to write initial balance for General Ledger"""
if "partner" in my_object["type"]:
label = _("Partner Initial balance")
elif "account" in my_object["type"]:
label = _("Initial balance")
return super(GeneralLedgerXslx, self).write_initial_balance_from_dict(
my_object, label, report_data
)
label = False
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)
def write_ending_balance_from_dict(self, my_object, report_data):
"""Specific function to write ending balance for General Ledger"""
if "partner" in my_object["type"]:
name = my_object["name"]
label = _("Partner ending balance")
elif "account" in my_object["type"]:
label = name = False
if "account" in my_object["type"]:
name = my_object["code"] + " - " + my_object["name"]
label = _("Ending balance")
return super(GeneralLedgerXslx, self).write_ending_balance_from_dict(
elif "grouped_by" in my_object:
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
)

View File

@ -35,48 +35,42 @@
<!-- 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="o._get_atr_from_dict(account['id'], accounts_data, 'code')"
/>
-
<span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'name')"
<span t-esc="account['code']" /> - <span
t-esc="account['name']"
/>
</div>
<t t-if="not account['partners']">
<t t-if="'list_grouped' not in account">
<!-- Display account move lines without partner regroup -->
<t t-set="type" t-value='"account_type"' />
<t
t-call="account_financial_report.report_general_ledger_lines"
>
<t t-set="account_or_partner_object" t-value="account" />
<t t-set="account_or_group_item_object" t-value="account" />
</t>
<!-- Display account footer -->
<t
t-call="account_financial_report.report_general_ledger_ending_cumul"
>
<t t-set="account_or_partner_object" t-value="account" />
<t t-set="account_or_group_item_object" t-value="account" />
<t t-set="type" t-value='"account_type"' />
</t>
</t>
<t t-if="account['partners']">
<t t-if="'list_grouped' in account">
<!-- Display account partners -->
<t t-foreach="account['list_partner']" t-as="partner">
<t t-set="type" t-value='"partner_type"' />
<t t-foreach="account['list_grouped']" t-as="group_item">
<t t-set="type" t-value='"grouped_type"' />
<div class="page_break">
<!-- Display partner header -->
<div class="act_as_caption account_title">
<span
t-esc="o._get_atr_from_dict(partner['id'], partners_data, 'name')"
/>
<span t-esc="group_item['name']" />
</div>
<!-- Display partner move lines -->
<t
t-call="account_financial_report.report_general_ledger_lines"
>
<t
t-set="account_or_partner_object"
t-value="partner"
t-set="account_or_group_item_object"
t-value="group_item"
/>
</t>
<!-- Display partner footer -->
@ -84,10 +78,10 @@
t-call="account_financial_report.report_general_ledger_ending_cumul"
>
<t
t-set="account_or_partner_object"
t-value="partner"
t-set="account_or_group_item_object"
t-value="group_item"
/>
<t t-set="type" t-value='"partner_type"' />
<t t-set="type" t-value='"grouped_type"' />
</t>
</div>
</t>
@ -97,7 +91,7 @@
t-call="account_financial_report.report_general_ledger_ending_cumul"
>
<t
t-set="account_or_partner_object"
t-set="account_or_group_item_object"
t-value="account"
/>
<t t-set="type" t-value='"account_type"' />
@ -216,7 +210,13 @@
<!--## partner-->
<div class="act_as_cell" />
<!--## ref - label-->
<div class="act_as_cell amount">Initial balance</div>
<div class="act_as_cell amount">
<t t-if='type == "account_type"'>Initial balance</t>
<t t-if='type == "grouped_type"'>
<t t-if="'partners' in account">Partner initial balance</t>
<t t-if="'taxes' in account">Tax initial balance</t>
</t>
</div>
<t t-if="show_cost_center">
<!--## cost_center-->
<div class="act_as_cell" />
@ -238,23 +238,23 @@
/>
<span t-att-domain="domain" res-model="account.move.line">
<t
t-raw="account_or_partner_object['init_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-raw="account_or_group_item_object['init_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/>
</span>
</t>
<t t-if="type == 'partner_type'">
<t t-if="type == 'grouped_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']),
('partner_id', '=', group_item['id']),
('date', '&lt;', date_from),
('debit', '&lt;&gt;', 0)]"
/>
<span t-att-domain="domain" res-model="account.move.line">
<t
t-raw="account_or_partner_object['init_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-raw="account_or_group_item_object['init_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/>
</span>
</t>
@ -270,23 +270,23 @@
/>
<span t-att-domain="domain" res-model="account.move.line">
<t
t-raw="account_or_partner_object['init_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-raw="account_or_group_item_object['init_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/>
</span>
</t>
<t t-if="type == 'partner_type'">
<t t-if="type == 'grouped_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']),
('partner_id', '=', group_item['id']),
('date', '&lt;', date_from),
('credit', '&lt;&gt;', 0)]"
/>
<span t-att-domain="domain" res-model="account.move.line">
<t
t-raw="account_or_partner_object['init_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-raw="account_or_group_item_object['init_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/>
</span>
</t>
@ -301,30 +301,28 @@
/>
<span t-att-domain="domain" res-model="account.move.line">
<t
t-raw="account_or_partner_object['init_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-raw="account_or_group_item_object['init_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/>
</span>
</t>
<t t-if="type == 'partner_type'">
<t t-if="type == 'grouped_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']),
('partner_id', '=', group_item['id']),
('date', '&lt;', date_from)]"
/>
<span t-att-domain="domain" res-model="account.move.line">
<t
t-raw="account_or_partner_object['init_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-raw="account_or_group_item_object['init_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/>
</span>
</t>
</div>
<t t-if="foreign_currency">
<t
t-if="o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<t t-if="account['currency_id']">
<div class="act_as_cell amount" style="width: 3.63%;">
<t t-if="type == 'account_type'">
<t
@ -337,16 +335,16 @@
res-model="account.move.line"
>
<t
t-raw="account_or_partner_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
t-raw="account_or_group_item_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/>
</span>
</t>
<t t-if="type == 'partner_type'">
<t t-if="type == 'grouped_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']),
('partner_id', '=', group_item['id']),
('date', '&lt;', o.date_from)]"
/>
<span
@ -354,17 +352,15 @@
res-model="account.move.line"
>
<t
t-raw="account_or_partner_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
t-raw="account_or_group_item_object['init_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/>
</span>
</t>
</div>
<div class="act_as_cell amount" style="width: 3.63%;" />
</t>
<t
t-if="not o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<t t-if="not account['currency_id']">
<div class="act_as_cell" style="width: 3.63%;" />
<div class="act_as_cell" style="width: 3.63%;" />
</t>
@ -372,7 +368,7 @@
</div>
<!-- Display each lines -->
<t t-set="total_bal_curr" t-value="0" />
<t t-foreach="account_or_partner_object['move_lines']" t-as="line">
<t t-foreach="account_or_group_item_object['move_lines']" t-as="line">
<!-- # lines or centralized lines -->
<div class="act_as_row lines">
<!--## date-->
@ -431,9 +427,7 @@
res-model="account.account"
view-type="form"
>
<t
t-raw="o._get_atr_from_dict(account['id'], accounts_data, 'code')"
/>
<t t-raw="account['code']" />
</span>
</div>
<!--## taxes-->
@ -445,6 +439,9 @@
/>
</t>
</t>
<t t-if="line['tax_line_id']">
<span t-esc="line['tax_line_id'][1]" />
</t>
</div>
<!--## partner-->
<div class="act_as_cell left">
@ -634,22 +631,20 @@
<!--## date-->
<t t-if='type == "account_type"'>
<div class="act_as_cell first_column" style="width: 41.32%;">
<span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, 'code')"
/>
-
<span
t-esc="o._get_atr_from_dict(account['id'], accounts_data, '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 == "partner_type"'>
<t t-if='type == "grouped_type"'>
<div class="act_as_cell first_column" style="width: 41.32%;" />
<div class="act_as_cell right" style="width: 16.9%;">
Partner ending balance
<t t-if="'partners' in account">Partner ending balance</t>
<t t-if="'taxes' in account">Tax ending balance</t>
</div>
</t>
<t t-if="show_cost_center">
@ -665,29 +660,27 @@
<!--## debit-->
<div class="act_as_cell amount" style="width: 8.02%;">
<span
t-esc="account_or_partner_object['fin_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-esc="account_or_group_item_object['fin_bal']['debit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/>
</div>
<!--## credit-->
<div class="act_as_cell amount" style="width: 8.02%;">
<span
t-esc="account_or_partner_object['fin_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-esc="account_or_group_item_object['fin_bal']['credit']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/>
</div>
<!--## balance cumulated-->
<div class="act_as_cell amount" style="width: 8.02%;">
<span
t-esc="account_or_partner_object['fin_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
t-esc="account_or_group_item_object['fin_bal']['balance']"
t-options="{'widget': 'monetary', 'display_currency': company_currency}"
/>
</div>
<!--## currency_name + amount_currency-->
<t t-if="foreign_currency">
<t
t-if="o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<t t-if="account['currency_id']">
<div class="act_as_cell amount" style="width: 3.63%;">
<t t-if="type == 'account_type'">
<t
@ -703,17 +696,17 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
t-raw="account_or_group_item_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/>
</a>
</span>
</t>
<t t-if="type == 'partner_type'">
<t t-if="type == 'grouped_type'">
<t
t-set="domain"
t-value="[('account_id', '=', account['id']),
('partner_id', '=', partner['id']),
('partner_id', '=', group_item['id']),
('date', '&lt;', date_from)]"
/>
<span>
@ -724,8 +717,8 @@
style="color: black;"
>
<t
t-raw="account_or_partner_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')}"
t-raw="account_or_group_item_object['fin_bal']['bal_curr']"
t-options="{'widget': 'monetary', 'display_currency': account['currency_id']}"
/>
</a>
</span>
@ -733,9 +726,7 @@
</div>
<div class="act_as_cell amount" style="width: 3.63%;" />
</t>
<t
t-if="not o._get_atr_from_dict(account['id'], accounts_data, 'currency_id')"
>
<t t-if="not account['currency_id']">
<div class="act_as_cell amount" style="width: 3.63%;" />
<div class="act_as_cell amount" style="width: 3.63%;" />
</t>

View File

@ -128,7 +128,7 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
partner_in_report = False
for account in general_ledger:
if account["id"] == account_id and account["partners"]:
for partner in account["list_partner"]:
for partner in account["list_grouped"]:
if partner["id"] == partner_id:
partner_in_report = True
return partner_in_report
@ -146,7 +146,7 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
initial_balance = False
for account in general_ledger:
if account["id"] == account_id and account["partners"]:
for partner in account["list_partner"]:
for partner in account["list_grouped"]:
if partner["id"] == partner_id:
initial_balance = partner["init_bal"]
return initial_balance
@ -164,7 +164,7 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
final_balance = False
for account in general_ledger:
if account["id"] == account_id and account["partners"]:
for partner in account["list_partner"]:
for partner in account["list_grouped"]:
if partner["id"] == partner_id:
final_balance = partner["fin_bal"]
return final_balance

View File

@ -77,8 +77,9 @@ class GeneralLedgerReportWizard(models.TransientModel):
comodel_name="account.account",
help="Ending account in a range",
)
show_partner_details = fields.Boolean(
default=True,
grouped_by = fields.Selection(
selection=[("none", "None"), ("partners", "Partners"), ("taxes", "Taxes")],
default="partners",
)
show_cost_center = fields.Boolean(
string="Show Analytic Account",
@ -298,7 +299,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids,
"show_partner_details": self.show_partner_details,
"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,

View File

@ -22,11 +22,11 @@
<field name="date_from" />
<field name="date_to" />
<field name="fy_start_date" invisible="1" />
<field name="target_move" widget="radio" />
</group>
<group name="other_filters">
<field name="target_move" widget="radio" />
<field name="grouped_by" />
<field name="centralize" />
<field name="show_partner_details" />
<field name="hide_account_at_0" />
<field name="foreign_currency" />
<field name="show_analytic_tags" />