Skip to content

Commit

Permalink
[MIG] account_chart_update: Finish migration
Browse files Browse the repository at this point in the history
Changes done:
- Purge translations
- Squash administrative commits
- Change name_get to _compute_display_name
- Change attrs to invisible/required
- Adapt to the new account.chart.template system without records
- Remove recreate_xml_ids fields (It is always necessary for them to have the expected xml_id)

TT49275
  • Loading branch information
victoralmau committed Dec 19, 2024
1 parent 04d4dc1 commit 49d121b
Show file tree
Hide file tree
Showing 13 changed files with 605 additions and 1,702 deletions.
1 change: 1 addition & 0 deletions account_chart_update/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Contributors

- Pedro M. Baeza
- Ernesto Tejeda
- Víctor Martínez

- Jacques-Etienne Baudoux <[email protected]>
- Sylvain Van Hoof <[email protected]>
Expand Down
31 changes: 0 additions & 31 deletions account_chart_update/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -915,34 +915,3 @@ msgid ""
"going to be created. Aborting as this will provoke an infinite loop. Please "
"check if children have been matched, but not the parent one."
msgstr ""

#~ msgid "<span states=\"init,ready\"> or </span>"
#~ msgstr "<span states=\"init,ready\"> oder </span>"

#~ msgid "Continue on errors"
#~ msgstr "Bei Fehlern fortfahren"

#~ msgid "New accounts"
#~ msgstr "Neue Konten"

#~ msgid "New taxes"
#~ msgstr "Neue Steuern"

#~ msgid "Updated accounts"
#~ msgstr "Aktualisierte Konten"

#~ msgid "Updated taxes"
#~ msgstr "Steuern aktualisiert"

#~ msgid "Post-updated tax %s."
#~ msgstr "Steuer %s aktualisiert."

#~ msgid "Tax Scope"
#~ msgstr "Steuerumfang"

#~ msgid ""
#~ "No. of digits to use for account code. Make sure it is the same number as "
#~ "existing accounts."
#~ msgstr ""
#~ "Anzahl Ziffern, die für die Kontenschlüssel verwendet werden. Stellen Sie "
#~ "bitte sicher, die gleiche Anzahl wie bestehende Konten zu verwenden."
31 changes: 0 additions & 31 deletions account_chart_update/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -914,34 +914,3 @@ msgstr ""
"Hay por lo menos una plantilla de impuestos padre (%s) cuyos impuestos hijo "
"no se van a crear. Cancela si no se provocará un loop infinito. Por favor "
"comprueba si los hijos han sido emparejados, pero el padre no."

#~ msgid "<span states=\"init,ready\"> or </span>"
#~ msgstr "<span states=\"init,ready\"> o </span>"

#~ msgid "Continue on errors"
#~ msgstr "Continuar con errores"

#~ msgid "New accounts"
#~ msgstr "Nuevas cuentas"

#~ msgid "New taxes"
#~ msgstr "Nuevos impuestos"

#~ msgid "Updated accounts"
#~ msgstr "Cuentas actualizadas"

#~ msgid "Updated taxes"
#~ msgstr "Impuestos actualizados"

#~ msgid "Post-updated tax %s."
#~ msgstr "Impuesto %s post-actualizado."

#~ msgid "Tax Scope"
#~ msgstr "Ámbito del impuesto"

#~ msgid ""
#~ "No. of digits to use for account code. Make sure it is the same number as "
#~ "existing accounts."
#~ msgstr ""
#~ "Nº de dígitos a usar para el código de cuenta. Asegúrese que es el mismo "
#~ "número que las cuentas existentes."
18 changes: 0 additions & 18 deletions account_chart_update/i18n/es_AR.po
Original file line number Diff line number Diff line change
Expand Up @@ -923,21 +923,3 @@ msgstr ""
"secundarios no se van a crear. Abortar esto provocará un bucle infinito. "
"Compruebe si los impuestos secundarios han sido emparejados, pero no el "
"principal."

#~ msgid "<span states=\"init,ready\"> or </span>"
#~ msgstr "<span states=\"init,ready\"> o </span>"

#~ msgid "Continue on errors"
#~ msgstr "Continuar con errores"

#~ msgid "New accounts"
#~ msgstr "Nuevas cuentas"

#~ msgid "New taxes"
#~ msgstr "Nuevos impuestos"

#~ msgid "Updated accounts"
#~ msgstr "Cuentas actualizadas"

#~ msgid "Updated taxes"
#~ msgstr "Impuestos actualizados"
6 changes: 0 additions & 6 deletions account_chart_update/i18n/hr.po
Original file line number Diff line number Diff line change
Expand Up @@ -908,9 +908,3 @@ msgstr ""
"Imate najmanje jedan nadređeni predložak poreza (%s) čiji podređeni porezi "
"neće biti kreirani. Ovakvo odustajanje će prouzročiti beskonačnu petlju. "
"Molimo provjerite jesu li podređeni usklađeni, ali ne i nadređeni porezi."

#~ msgid "<span states=\"init,ready\"> or </span>"
#~ msgstr "<span states=\"init,ready\"> ili </span>"

#~ msgid "Continue on errors"
#~ msgstr "Nastavi u slučaju greške"
13 changes: 7 additions & 6 deletions account_chart_update/models/ir_model_fields.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Copyright 2018 Tecnativa - Pedro M. Baeza
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models
from odoo import api, models


class IrModelFields(models.Model):
_inherit = "ir.model.fields"

def name_get(self):
@api.depends_context("account_chart_update")
def _compute_display_name(self):
"""Return special label when showing fields in chart update wizard."""
res = super()._compute_display_name()
if self.env.context.get("account_chart_update"):
res = []
for record in self:
res.append((record.id, f"{record.field_description} ({record.name})"))
return res
return super().name_get()
record.display_name = f"{record.field_description} ({record.name})"
return res
1 change: 1 addition & 0 deletions account_chart_update/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- [Tecnativa](https://www.tecnativa.com):
- Pedro M. Baeza
- Ernesto Tejeda
- Víctor Martínez
- Jacques-Etienne Baudoux \<<[email protected]>\>
- Sylvain Van Hoof \<<[email protected]>\>
- Nacho Muñoz \<<[email protected]>\>
Expand Down
1 change: 1 addition & 0 deletions account_chart_update/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Pedro M. Baeza</li>
<li>Ernesto Tejeda</li>
<li>Víctor Martínez</li>
</ul>
</li>
<li>Jacques-Etienne Baudoux &lt;<a class="reference external" href="mailto:je&#64;bcim.be">je&#64;bcim.be</a>&gt;</li>
Expand Down
182 changes: 15 additions & 167 deletions account_chart_update/tests/common.py
Original file line number Diff line number Diff line change
@@ -1,102 +1,14 @@
# Copyright 2023 Tecnativa - Pedro M. Baeza
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests import common, tagged
from odoo.tests import tagged

from odoo.addons.base.tests.common import BaseCommon

@tagged("-at_install", "post_install")
class TestAccountChartUpdateCommon(common.TransactionCase):
@classmethod
def _create_xml_id(cls, record):
return cls.env["ir.model.data"].create(
{
"module": "account_chart_update",
"name": f"{record._table}-{record.id}",
"model": record._name,
"res_id": record.id,
}
)

@classmethod
def _create_account_tmpl(cls, name, code, account_type, chart_template):
record = cls.env["account.account.template"].create(
{
"name": name,
"code": code,
"account_type": account_type,
"chart_template_id": chart_template and chart_template.id,
}
)
cls._create_xml_id(record)
return record

@classmethod
def _create_tax_tmpl(cls, name, chart_template):
record = cls.env["account.tax.template"].create(
{
"name": name,
"amount": 0,
"chart_template_id": chart_template.id,
"tax_group_id": cls.env.ref("account.tax_group_taxes").id,
"refund_repartition_line_ids": [
(0, 0, {"repartition_type": "base", "factor_percent": 100.0}),
(0, 0, {"repartition_type": "tax", "factor_percent": 100.0}),
(0, 0, {"repartition_type": "tax", "factor_percent": 100.0}),
],
"invoice_repartition_line_ids": [
(0, 0, {"repartition_type": "base", "factor_percent": 100.0}),
(0, 0, {"repartition_type": "tax", "factor_percent": 100.0}),
(0, 0, {"repartition_type": "tax", "factor_percent": 100.0}),
],
}
)
cls._create_xml_id(record)
return record

def _create_tax_template_with_account(self, name, chart_template, account):
record = self.env["account.tax.template"].create(
{
"name": name,
"amount": 0,
"chart_template_id": chart_template.id,
"tax_group_id": self.env.ref("account.tax_group_taxes").id,
"refund_repartition_line_ids": [
(0, 0, {"repartition_type": "base", "factor_percent": 100.0}),
(
0,
0,
{
"repartition_type": "tax",
"factor_percent": 100.0,
"account_id": account.id,
},
),
],
"invoice_repartition_line_ids": [
(0, 0, {"repartition_type": "base", "factor_percent": 100.0}),
(
0,
0,
{
"repartition_type": "tax",
"factor_percent": 100.0,
"account_id": account.id,
},
),
],
}
)
self._create_xml_id(record)
return record

@classmethod
def _create_fp_tmpl(cls, name, chart_template):
record = cls.env["account.fiscal.position.template"].create(
{"name": name, "chart_template_id": chart_template.id}
)
cls._create_xml_id(record)
return record

@tagged("-at_install", "post_install")
class TestAccountChartUpdateCommon(BaseCommon):
def _get_model_data(self, record):
return self.env["ir.model.data"].search(
[("model", "=", record._name), ("res_id", "=", record.id)]
Expand All @@ -105,92 +17,28 @@ def _get_model_data(self, record):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(
context=dict(
cls.env.context,
mail_create_nolog=True,
mail_create_nosubscribe=True,
mail_notrack=True,
no_reset_password=True,
tracking_disable=True,
)
)
cls.account_template = cls._create_account_tmpl(
"Test", "100000", "income", False
)
cls.chart_template = cls.env["account.chart.template"].create(
{
"name": "Test account_chart_update chart",
"currency_id": cls.env.ref("base.EUR").id,
"code_digits": 6,
"cash_account_code_prefix": "570",
"bank_account_code_prefix": "572",
"transfer_account_code_prefix": "100000",
"property_account_receivable_id": cls.account_template.id,
"property_account_payable_id": cls.account_template.id,
"property_account_expense_categ_id": cls.account_template.id,
"property_account_income_categ_id": cls.account_template.id,
}
)
cls.account_template.chart_template_id = cls.chart_template.id
cls.account_template_pl = cls._create_account_tmpl(
"Undistributed Profits/Losses",
"999999",
"equity",
cls.chart_template,
)
cls.tax_template = cls._create_tax_tmpl("Test tax", cls.chart_template)
cls.fp_template = cls._create_fp_tmpl("Test fp", cls.chart_template)
cls.fp_template_tax = cls.env["account.fiscal.position.tax.template"].create(
{"tax_src_id": cls.tax_template.id, "position_id": cls.fp_template.id}
)
cls._create_xml_id(cls.fp_template_tax)
cls.fp_template_account = cls.env[
"account.fiscal.position.account.template"
].create(
{
"account_src_id": cls.account_template.id,
"account_dest_id": cls.account_template.id,
"position_id": cls.fp_template.id,
}
)
cls._create_xml_id(cls.fp_template_account)
cls.tax_group = cls.env["account.tax.group"].create({"name": "Test tax group"})
cls.account_tag_1 = cls.env["account.account.tag"].create(
{"name": "Test account tag 1"}
)
cls.account_tag_2 = cls.env["account.account.tag"].create(
{"name": "Test account tag 2"}
)
cls.company = cls.env["res.company"].create(
{
"name": "Test account_chart_update company",
"currency_id": cls.chart_template.currency_id.id,
"country_id": cls.env.ref("base.es").id,
"country_id": cls.env.ref("base.us").id,
}
)
chart_by_company_user = cls.chart_template.with_company(cls.company)
chart_by_company_user.try_loading()
cls.tax = cls.env["account.tax"].search(
template = cls.env["account.chart.template"]
template.try_loading("generic_coa", cls.company)
cls.chart_template_data = template._get_chart_template_data("generic_coa")
# We delete the records so that we can later delete the linked data
moves = cls.env["account.move"].search(
[
("name", "=", cls.tax_template.name),
("company_id", "=", cls.company.id),
]
)
cls.account = cls.env["account.account"].search(
[
("code", "=", cls.account_template.code),
("company_id", "=", cls.company.id),
]
)
cls.fp = cls.env["account.fiscal.position"].search(
[("name", "=", cls.fp_template.name), ("company_id", "=", cls.company.id)]
)
# Prepare wizard values
moves.filtered(lambda x: x.state == "posted").button_draft()
moves.unlink()
# Prepare wizard
cls.wizard_obj = cls.env["wizard.update.charts.accounts"]
cls.wizard_vals = {
"company_id": cls.company.id,
"chart_template_id": cls.chart_template.id,
"chart_template": "generic_coa",
"code_digits": 6,
"lang": "en_US",
}
Loading

0 comments on commit 49d121b

Please sign in to comment.