Skip to content

Commit

Permalink
[IMP] oxigen_account: convert the trial balance to multi-company
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankC013 committed Sep 18, 2024
1 parent 976eef3 commit 53f5559
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 13 deletions.
2 changes: 1 addition & 1 deletion oxigen_account/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import models, wizards
from . import models, wizards, report
4 changes: 3 additions & 1 deletion oxigen_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
"author": "ForgeFlow",
"website": "https://github.com/oxigensalud/odoo-addons",
"category": "Accounting",
"depends": ["account_lock_date_update", "contract"],
"depends": ["account_lock_date_update", "contract", "account_financial_report"],
"installable": True,
"license": "AGPL-3",
"data": [
"wizards/draft_invoices.xml",
"views/account_move_views.xml",
"views/report_invoice.xml",
"wizards/trial_balance_wizard_views.xml",
"report/templates/trial_balance.xml",
],
}
79 changes: 68 additions & 11 deletions oxigen_account/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-01 15:02+0000\n"
"PO-Revision-Date: 2022-06-01 15:02+0000\n"
"POT-Creation-Date: 2024-09-18 15:32+0000\n"
"PO-Revision-Date: 2024-09-18 15:32+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -18,12 +18,17 @@ msgstr ""
#. module: oxigen_account
#: model_terms:ir.ui.view,arch_db:oxigen_account.report_assets_common
msgid "<strong>Reference:</strong>"
msgstr ""
msgstr "<strong>Referencia:</strong>"

#. module: oxigen_account
#: model_terms:ir.ui.view,arch_db:oxigen_account.report_assets_common
msgid "<strong>Source:</strong>"
msgstr ""
msgstr "<strong>Origen:</strong>"

#. module: oxigen_account
#: model:ir.model,name:oxigen_account.model_report_account_financial_report_abstract_report
msgid "Abstract Report"
msgstr "Informe Extracto"

#. module: oxigen_account
#: model:ir.model,name:oxigen_account.model_account_update_lock_date
Expand All @@ -33,7 +38,7 @@ msgstr "Actualización de fecha de bloqueo contable"
#. module: oxigen_account
#: model_terms:ir.ui.view,arch_db:oxigen_account.view_change_draft_date
msgid "Cancel"
msgstr ""
msgstr "Cancelar"

#. module: oxigen_account
#: model_terms:ir.ui.view,arch_db:oxigen_account.view_change_draft_date
Expand All @@ -60,15 +65,27 @@ msgstr "Cambiar/Mostrar asientos en borrador"

#. module: oxigen_account
#: model:ir.model,name:oxigen_account.model_res_company
#: model:ir.model.fields,field_description:oxigen_account.field_trial_balance_report_wizard__company_ids
msgid "Companies"
msgstr "Compañías"

#. module: oxigen_account
#: code:addons/oxigen_account/report/trial_balance_xlsx.py:0
#: model_terms:ir.ui.view,arch_db:oxigen_account.report_trial_balance_lines_header_oxigen
#, python-format
msgid "Company"
msgstr "Compañía"

#. module: oxigen_account
#: model:ir.model.fields,field_description:oxigen_account.field_account_journal__display_name
#: model:ir.model.fields,field_description:oxigen_account.field_account_move__display_name
#: model:ir.model.fields,field_description:oxigen_account.field_account_move_line__display_name
#: model:ir.model.fields,field_description:oxigen_account.field_account_update_lock_date__display_name
#: model:ir.model.fields,field_description:oxigen_account.field_report_a_f_r_report_trial_balance_xlsx__display_name
#: model:ir.model.fields,field_description:oxigen_account.field_report_account_financial_report_abstract_report__display_name
#: model:ir.model.fields,field_description:oxigen_account.field_report_account_financial_report_trial_balance__display_name
#: model:ir.model.fields,field_description:oxigen_account.field_res_company__display_name
#: model:ir.model.fields,field_description:oxigen_account.field_trial_balance_report_wizard__display_name
msgid "Display Name"
msgstr "Nombre mostrado"

Expand All @@ -77,12 +94,26 @@ msgstr "Nombre mostrado"
msgid "Draft entries date changed successfully!"
msgstr "Fecha de los asientos en borrador cambiada!"

#. module: oxigen_account
#: code:addons/oxigen_account/models/account_move.py:0
#, python-format
msgid ""
"Duplicated vendor reference detected. You probably encoded twice the same vendor bill/credit note:\n"
"%s"
msgstr ""
"Se ha detectado una referencia de proveedor duplicada. Probablemente haya codificado dos veces la misma factura/nota de crédito de proveedor:\n"
"%s"

#. module: oxigen_account
#: model:ir.model.fields,field_description:oxigen_account.field_account_journal__id
#: model:ir.model.fields,field_description:oxigen_account.field_account_move__id
#: model:ir.model.fields,field_description:oxigen_account.field_account_move_line__id
#: model:ir.model.fields,field_description:oxigen_account.field_account_update_lock_date__id
#: model:ir.model.fields,field_description:oxigen_account.field_report_a_f_r_report_trial_balance_xlsx__id
#: model:ir.model.fields,field_description:oxigen_account.field_report_account_financial_report_abstract_report__id
#: model:ir.model.fields,field_description:oxigen_account.field_report_account_financial_report_trial_balance__id
#: model:ir.model.fields,field_description:oxigen_account.field_res_company__id
#: model:ir.model.fields,field_description:oxigen_account.field_trial_balance_report_wizard__id
msgid "ID"
msgstr ""

Expand All @@ -101,6 +132,11 @@ msgstr ""
"conciliación, las transacciones en cuestión se conciliarán con los asientos "
"en la Cuenta de recibos pendientes en lugar de la cuenta por cobrar."

#. module: oxigen_account
#: model_terms:ir.ui.view,arch_db:oxigen_account.oxigen_view_account_invoice_filter
msgid "Invoice Line"
msgstr "Línea de factura"

#. module: oxigen_account
#: model:ir.model,name:oxigen_account.model_account_journal
msgid "Journal"
Expand All @@ -121,15 +157,19 @@ msgstr "Apunte contable"
#: model:ir.model.fields,field_description:oxigen_account.field_account_move____last_update
#: model:ir.model.fields,field_description:oxigen_account.field_account_move_line____last_update
#: model:ir.model.fields,field_description:oxigen_account.field_account_update_lock_date____last_update
#: model:ir.model.fields,field_description:oxigen_account.field_report_a_f_r_report_trial_balance_xlsx____last_update
#: model:ir.model.fields,field_description:oxigen_account.field_report_account_financial_report_abstract_report____last_update
#: model:ir.model.fields,field_description:oxigen_account.field_report_account_financial_report_trial_balance____last_update
#: model:ir.model.fields,field_description:oxigen_account.field_res_company____last_update
#: model:ir.model.fields,field_description:oxigen_account.field_trial_balance_report_wizard____last_update
msgid "Last Modified on"
msgstr "Última modificación"

#. module: oxigen_account
#: code:addons/oxigen_account/models/account_move.py:0
#, python-format
msgid "Less Payment"
msgstr ""
msgstr "Pago menor"

#. module: oxigen_account
#: model:ir.model.fields,help:oxigen_account.field_account_journal__payment_credit_account_id
Expand Down Expand Up @@ -165,24 +205,24 @@ msgstr "Restablecer a borrador (manteniendo apuntes conciliados)"
#. module: oxigen_account
#: model:ir.model.fields,field_description:oxigen_account.field_account_update_lock_date__show_change_date_msg
msgid "Show Change Date Msg"
msgstr ""
msgstr "Mostrar mensaje de cambio de fecha"

#. module: oxigen_account
#: code:addons/oxigen_account/models/res_company.py:0
#, python-format
msgid "Show Unreconciled Bank Statement Line"
msgstr ""
msgstr "Mostrar líneas de extracto bancario no conciliadas"

#. module: oxigen_account
#: model_terms:ir.ui.view,arch_db:oxigen_account.view_change_draft_date
msgid "Show unposted entries"
msgstr ""
msgstr "Mostrar asientos sin publicar"

#. module: oxigen_account
#: code:addons/oxigen_account/models/res_company.py:0
#, python-format
msgid "There are still unposted entries in the period you want to lock."
msgstr ""
msgstr "Existen asientos sin publicar en el período que desea bloquear."

#. module: oxigen_account
#: code:addons/oxigen_account/models/res_company.py:0
Expand All @@ -191,6 +231,8 @@ msgid ""
"There are still unreconciled bank statement lines in the period you want to "
"lock. You should either reconcile or delete them."
msgstr ""
"Aún hay líneas de extracto bancario no conciliadas en el período que desea "
"bloquear. Debería conciliarlas o eliminarlas."

#. module: oxigen_account
#: model_terms:ir.ui.view,arch_db:oxigen_account.oxigen_view_invoice_tree
Expand All @@ -207,7 +249,22 @@ msgstr "Total (moneda)"
msgid "Total (€)"
msgstr ""

#. module: oxigen_account
#: model:ir.model,name:oxigen_account.model_report_account_financial_report_trial_balance
msgid "Trial Balance Report"
msgstr "Informe Balance de Sumas y Saldos"

#. module: oxigen_account
#: model:ir.model,name:oxigen_account.model_trial_balance_report_wizard
msgid "Trial Balance Report Wizard"
msgstr "Asistente del informe de balance de sumas y saldos"

#. module: oxigen_account
#: model:ir.model,name:oxigen_account.model_report_a_f_r_report_trial_balance_xlsx
msgid "Trial Balance XLSX Report"
msgstr "Balance de Sumas y Saldos XLSX"

#. module: oxigen_account
#: model_terms:ir.ui.view,arch_db:oxigen_account.view_change_draft_date
msgid "Unposted entries"
msgstr ""
msgstr "Asientos no contabilizados"
3 changes: 3 additions & 0 deletions oxigen_account/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import trial_balance
from . import abstract_report
from . import trial_balance_xlsx
15 changes: 15 additions & 0 deletions oxigen_account/report/abstract_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright NuoBiT - Frank Cespedes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import models


class AccountFinancialAbstractReport(models.AbstractModel):
_inherit = "report.account_financial_report.abstract_report"

def _get_accounts_data(self, accounts_ids):
accounts_data = super()._get_accounts_data(accounts_ids)
accounts = self.env["account.account"].browse(accounts_ids)
for account in accounts:
accounts_data[account.id]["company"] = account.company_id.name
return accounts_data
37 changes: 37 additions & 0 deletions oxigen_account/report/templates/trial_balance.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright NuoBiT - Frank Cespedes <[email protected]>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -->
<odoo>
<template
id="report_trial_balance_lines_header_oxigen"
inherit_id="account_financial_report.report_trial_balance_lines_header"
priority="100"
>
<xpath
expr="//div[hasclass('act_as_row') and hasclass('labels')]/t[@t-if='not show_partner_details']"
position="before"
>
<div class="act_as_cell" style="width: 9%;">Company</div>
</xpath>
</template>
<template
id="report_trial_balance_line_oxigen"
inherit_id="account_financial_report.report_trial_balance_line"
priority="100"
>
<xpath
expr="//div[hasclass('act_as_row') and hasclass('lines')]/t[@t-if='not show_partner_details']"
position="before"
>
<div class="act_as_cell left" t-att-style="style">
<span
t-att-res-id="balance['id']"
res-model="account.account"
view-type="form"
>
<t t-esc="balance['company']" />
</span>
</div>
</xpath>
</template>
</odoo>
66 changes: 66 additions & 0 deletions oxigen_account/report/trial_balance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright NuoBiT - Frank Cespedes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import api, models


class TrialBalanceReport(models.AbstractModel):
_inherit = "report.account_financial_report.trial_balance"

def _get_groups_data(self, accounts_data, total_amount, foreign_currency):
return super(TrialBalanceReport, self.sudo())._get_groups_data(
accounts_data, total_amount, foreign_currency
)

def _get_hierarchy_groups(self, group_ids, groups_data, foreign_currency):
groups_data = super()._get_hierarchy_groups(
group_ids, groups_data, foreign_currency
)
for group_id in groups_data.keys():
group = self.env["account.group"].browse(group_id)
groups_data[group_id]["company"] = group.company_id.name
return groups_data

def _get_report_values(self, docids, data=None):
company_ids = data.get("company_ids", [])
if company_ids:
self = self.with_context(company_ids=company_ids)
return super(TrialBalanceReport, self)._get_report_values(docids, data)

@api.model
def _get_data(
self,
account_ids,
journal_ids,
partner_ids,
company_id,
date_to,
date_from,
foreign_currency,
only_posted_moves,
show_partner_details,
hide_account_at_0,
unaffected_earnings_account,
fy_start_date,
):
company_ids = self.env.context.get("company_ids", [])
total_amount, accounts_data, partners_data = {}, {}, []
for company_id in company_ids:
ta, ad, pd = super(TrialBalanceReport, self.sudo())._get_data(
account_ids,
journal_ids,
partner_ids,
company_id,
date_to,
date_from,
foreign_currency,
only_posted_moves,
show_partner_details,
hide_account_at_0,
unaffected_earnings_account,
fy_start_date,
)
total_amount.update(ta)
accounts_data.update(ad)
partners_data.extend(pd)
return total_amount, accounts_data, partners_data
19 changes: 19 additions & 0 deletions oxigen_account/report/trial_balance_xlsx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright NuoBiT - Frank Cespedes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import _, models


class TrialBalanceXslx(models.AbstractModel):
_inherit = "report.a_f_r.report_trial_balance_xlsx"

def _get_report_columns(self, report):
res = super()._get_report_columns(report)
return {
0: {
"header": _("Company"),
"field": "company",
"width": 20,
},
**{key + 1: value for key, value in res.items()},
}
1 change: 1 addition & 0 deletions oxigen_account/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import change_date_draft_invoices
from . import trial_balance_wizard
25 changes: 25 additions & 0 deletions oxigen_account/wizards/trial_balance_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright NuoBiT - Frank Cespedes <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import api, fields, models


class TrialBalanceReportWizard(models.TransientModel):
_inherit = "trial.balance.report.wizard"

@api.model
def _get_company_domain(self):
return [("id", "in", self.env.user.company_ids.ids)]

company_ids = fields.Many2many(
comodel_name="res.company",
default=lambda self: self.env.company.ids,
required=False,
domain=lambda self: self._get_company_domain(),
string="Companies",
)

def _prepare_report_trial_balance(self):
data = super()._prepare_report_trial_balance()
data["company_ids"] = self.company_ids.ids
return data
Loading

0 comments on commit 53f5559

Please sign in to comment.