Skip to content

Commit bd53f36

Browse files
committed
[MIG] account_chart_update: Finish migration
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
1 parent 67172c2 commit bd53f36

File tree

15 files changed

+739
-1774
lines changed

15 files changed

+739
-1774
lines changed

account_chart_update/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Contributors
9494

9595
- Pedro M. Baeza
9696
- Ernesto Tejeda
97+
- Víctor Martínez
9798

9899
- Jacques-Etienne Baudoux <[email protected]>
99100
- Sylvain Van Hoof <[email protected]>

account_chart_update/i18n/de.po

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -915,34 +915,3 @@ msgid ""
915915
"going to be created. Aborting as this will provoke an infinite loop. Please "
916916
"check if children have been matched, but not the parent one."
917917
msgstr ""
918-
919-
#~ msgid "<span states=\"init,ready\"> or </span>"
920-
#~ msgstr "<span states=\"init,ready\"> oder </span>"
921-
922-
#~ msgid "Continue on errors"
923-
#~ msgstr "Bei Fehlern fortfahren"
924-
925-
#~ msgid "New accounts"
926-
#~ msgstr "Neue Konten"
927-
928-
#~ msgid "New taxes"
929-
#~ msgstr "Neue Steuern"
930-
931-
#~ msgid "Updated accounts"
932-
#~ msgstr "Aktualisierte Konten"
933-
934-
#~ msgid "Updated taxes"
935-
#~ msgstr "Steuern aktualisiert"
936-
937-
#~ msgid "Post-updated tax %s."
938-
#~ msgstr "Steuer %s aktualisiert."
939-
940-
#~ msgid "Tax Scope"
941-
#~ msgstr "Steuerumfang"
942-
943-
#~ msgid ""
944-
#~ "No. of digits to use for account code. Make sure it is the same number as "
945-
#~ "existing accounts."
946-
#~ msgstr ""
947-
#~ "Anzahl Ziffern, die für die Kontenschlüssel verwendet werden. Stellen Sie "
948-
#~ "bitte sicher, die gleiche Anzahl wie bestehende Konten zu verwenden."

account_chart_update/i18n/es.po

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -914,34 +914,3 @@ msgstr ""
914914
"Hay por lo menos una plantilla de impuestos padre (%s) cuyos impuestos hijo "
915915
"no se van a crear. Cancela si no se provocará un loop infinito. Por favor "
916916
"comprueba si los hijos han sido emparejados, pero el padre no."
917-
918-
#~ msgid "<span states=\"init,ready\"> or </span>"
919-
#~ msgstr "<span states=\"init,ready\"> o </span>"
920-
921-
#~ msgid "Continue on errors"
922-
#~ msgstr "Continuar con errores"
923-
924-
#~ msgid "New accounts"
925-
#~ msgstr "Nuevas cuentas"
926-
927-
#~ msgid "New taxes"
928-
#~ msgstr "Nuevos impuestos"
929-
930-
#~ msgid "Updated accounts"
931-
#~ msgstr "Cuentas actualizadas"
932-
933-
#~ msgid "Updated taxes"
934-
#~ msgstr "Impuestos actualizados"
935-
936-
#~ msgid "Post-updated tax %s."
937-
#~ msgstr "Impuesto %s post-actualizado."
938-
939-
#~ msgid "Tax Scope"
940-
#~ msgstr "Ámbito del impuesto"
941-
942-
#~ msgid ""
943-
#~ "No. of digits to use for account code. Make sure it is the same number as "
944-
#~ "existing accounts."
945-
#~ msgstr ""
946-
#~ "Nº de dígitos a usar para el código de cuenta. Asegúrese que es el mismo "
947-
#~ "número que las cuentas existentes."

account_chart_update/i18n/es_AR.po

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -923,21 +923,3 @@ msgstr ""
923923
"secundarios no se van a crear. Abortar esto provocará un bucle infinito. "
924924
"Compruebe si los impuestos secundarios han sido emparejados, pero no el "
925925
"principal."
926-
927-
#~ msgid "<span states=\"init,ready\"> or </span>"
928-
#~ msgstr "<span states=\"init,ready\"> o </span>"
929-
930-
#~ msgid "Continue on errors"
931-
#~ msgstr "Continuar con errores"
932-
933-
#~ msgid "New accounts"
934-
#~ msgstr "Nuevas cuentas"
935-
936-
#~ msgid "New taxes"
937-
#~ msgstr "Nuevos impuestos"
938-
939-
#~ msgid "Updated accounts"
940-
#~ msgstr "Cuentas actualizadas"
941-
942-
#~ msgid "Updated taxes"
943-
#~ msgstr "Impuestos actualizados"

account_chart_update/i18n/hr.po

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -908,9 +908,3 @@ msgstr ""
908908
"Imate najmanje jedan nadređeni predložak poreza (%s) čiji podređeni porezi "
909909
"neće biti kreirani. Ovakvo odustajanje će prouzročiti beskonačnu petlju. "
910910
"Molimo provjerite jesu li podređeni usklađeni, ali ne i nadređeni porezi."
911-
912-
#~ msgid "<span states=\"init,ready\"> or </span>"
913-
#~ msgstr "<span states=\"init,ready\"> ili </span>"
914-
915-
#~ msgid "Continue on errors"
916-
#~ msgstr "Nastavi u slučaju greške"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
22

3+
from . import account_chart_template
34
from . import ir_model_fields
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2025 Tecnativa - Víctor Martínez
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
6+
7+
class AccountChartTemplate(models.AbstractModel):
8+
_inherit = "account.chart.template"
9+
10+
def _get_chart_template_mapping(self, get_all=False):
11+
chart_template_mapping = super()._get_chart_template_mapping(get_all=get_all)
12+
if self.env.context.get("chart_template_only_installed"):
13+
return dict(
14+
(_template_code, template)
15+
for (_template_code, template) in chart_template_mapping.items()
16+
if template["installed"]
17+
)
18+
return chart_template_mapping
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# Copyright 2018 Tecnativa - Pedro M. Baeza
2+
# Copyright 2024 Tecnativa - Víctor Martínez
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
34

4-
from odoo import models
5+
from odoo import api, models
56

67

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

10-
def name_get(self):
11+
@api.depends_context("account_chart_update")
12+
def _compute_display_name(self):
1113
"""Return special label when showing fields in chart update wizard."""
14+
res = super()._compute_display_name()
1215
if self.env.context.get("account_chart_update"):
13-
res = []
1416
for record in self:
15-
res.append((record.id, f"{record.field_description} ({record.name})"))
16-
return res
17-
return super().name_get()
17+
record.display_name = f"{record.field_description} ({record.name})"
18+
return res

account_chart_update/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- [Tecnativa](https://www.tecnativa.com):
22
- Pedro M. Baeza
33
- Ernesto Tejeda
4+
- Víctor Martínez
45
- Jacques-Etienne Baudoux \<<[email protected]>\>
56
- Sylvain Van Hoof \<<[email protected]>\>
67
- Nacho Muñoz \<<[email protected]>\>

account_chart_update/static/description/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
440440
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
441441
<li>Pedro M. Baeza</li>
442442
<li>Ernesto Tejeda</li>
443+
<li>Víctor Martínez</li>
443444
</ul>
444445
</li>
445446
<li>Jacques-Etienne Baudoux &lt;<a class="reference external" href="mailto:je&#64;bcim.be">je&#64;bcim.be</a>&gt;</li>

account_chart_update/tests/common.py

Lines changed: 15 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,14 @@
11
# Copyright 2023 Tecnativa - Pedro M. Baeza
2+
# Copyright 2024 Tecnativa - Víctor Martínez
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
34

4-
from odoo.tests import common, tagged
5+
from odoo.tests import tagged
56

7+
from odoo.addons.base.tests.common import BaseCommon
68

7-
@tagged("-at_install", "post_install")
8-
class TestAccountChartUpdateCommon(common.TransactionCase):
9-
@classmethod
10-
def _create_xml_id(cls, record):
11-
return cls.env["ir.model.data"].create(
12-
{
13-
"module": "account_chart_update",
14-
"name": f"{record._table}-{record.id}",
15-
"model": record._name,
16-
"res_id": record.id,
17-
}
18-
)
19-
20-
@classmethod
21-
def _create_account_tmpl(cls, name, code, account_type, chart_template):
22-
record = cls.env["account.account.template"].create(
23-
{
24-
"name": name,
25-
"code": code,
26-
"account_type": account_type,
27-
"chart_template_id": chart_template and chart_template.id,
28-
}
29-
)
30-
cls._create_xml_id(record)
31-
return record
32-
33-
@classmethod
34-
def _create_tax_tmpl(cls, name, chart_template):
35-
record = cls.env["account.tax.template"].create(
36-
{
37-
"name": name,
38-
"amount": 0,
39-
"chart_template_id": chart_template.id,
40-
"tax_group_id": cls.env.ref("account.tax_group_taxes").id,
41-
"refund_repartition_line_ids": [
42-
(0, 0, {"repartition_type": "base", "factor_percent": 100.0}),
43-
(0, 0, {"repartition_type": "tax", "factor_percent": 100.0}),
44-
(0, 0, {"repartition_type": "tax", "factor_percent": 100.0}),
45-
],
46-
"invoice_repartition_line_ids": [
47-
(0, 0, {"repartition_type": "base", "factor_percent": 100.0}),
48-
(0, 0, {"repartition_type": "tax", "factor_percent": 100.0}),
49-
(0, 0, {"repartition_type": "tax", "factor_percent": 100.0}),
50-
],
51-
}
52-
)
53-
cls._create_xml_id(record)
54-
return record
55-
56-
def _create_tax_template_with_account(self, name, chart_template, account):
57-
record = self.env["account.tax.template"].create(
58-
{
59-
"name": name,
60-
"amount": 0,
61-
"chart_template_id": chart_template.id,
62-
"tax_group_id": self.env.ref("account.tax_group_taxes").id,
63-
"refund_repartition_line_ids": [
64-
(0, 0, {"repartition_type": "base", "factor_percent": 100.0}),
65-
(
66-
0,
67-
0,
68-
{
69-
"repartition_type": "tax",
70-
"factor_percent": 100.0,
71-
"account_id": account.id,
72-
},
73-
),
74-
],
75-
"invoice_repartition_line_ids": [
76-
(0, 0, {"repartition_type": "base", "factor_percent": 100.0}),
77-
(
78-
0,
79-
0,
80-
{
81-
"repartition_type": "tax",
82-
"factor_percent": 100.0,
83-
"account_id": account.id,
84-
},
85-
),
86-
],
87-
}
88-
)
89-
self._create_xml_id(record)
90-
return record
91-
92-
@classmethod
93-
def _create_fp_tmpl(cls, name, chart_template):
94-
record = cls.env["account.fiscal.position.template"].create(
95-
{"name": name, "chart_template_id": chart_template.id}
96-
)
97-
cls._create_xml_id(record)
98-
return record
999

10+
@tagged("-at_install", "post_install")
11+
class TestAccountChartUpdateCommon(BaseCommon):
10012
def _get_model_data(self, record):
10113
return self.env["ir.model.data"].search(
10214
[("model", "=", record._name), ("res_id", "=", record.id)]
@@ -105,92 +17,27 @@ def _get_model_data(self, record):
10517
@classmethod
10618
def setUpClass(cls):
10719
super().setUpClass()
108-
cls.env = cls.env(
109-
context=dict(
110-
cls.env.context,
111-
mail_create_nolog=True,
112-
mail_create_nosubscribe=True,
113-
mail_notrack=True,
114-
no_reset_password=True,
115-
tracking_disable=True,
116-
)
117-
)
118-
cls.account_template = cls._create_account_tmpl(
119-
"Test", "100000", "income", False
120-
)
121-
cls.chart_template = cls.env["account.chart.template"].create(
122-
{
123-
"name": "Test account_chart_update chart",
124-
"currency_id": cls.env.ref("base.EUR").id,
125-
"code_digits": 6,
126-
"cash_account_code_prefix": "570",
127-
"bank_account_code_prefix": "572",
128-
"transfer_account_code_prefix": "100000",
129-
"property_account_receivable_id": cls.account_template.id,
130-
"property_account_payable_id": cls.account_template.id,
131-
"property_account_expense_categ_id": cls.account_template.id,
132-
"property_account_income_categ_id": cls.account_template.id,
133-
}
134-
)
135-
cls.account_template.chart_template_id = cls.chart_template.id
136-
cls.account_template_pl = cls._create_account_tmpl(
137-
"Undistributed Profits/Losses",
138-
"999999",
139-
"equity",
140-
cls.chart_template,
141-
)
142-
cls.tax_template = cls._create_tax_tmpl("Test tax", cls.chart_template)
143-
cls.fp_template = cls._create_fp_tmpl("Test fp", cls.chart_template)
144-
cls.fp_template_tax = cls.env["account.fiscal.position.tax.template"].create(
145-
{"tax_src_id": cls.tax_template.id, "position_id": cls.fp_template.id}
146-
)
147-
cls._create_xml_id(cls.fp_template_tax)
148-
cls.fp_template_account = cls.env[
149-
"account.fiscal.position.account.template"
150-
].create(
151-
{
152-
"account_src_id": cls.account_template.id,
153-
"account_dest_id": cls.account_template.id,
154-
"position_id": cls.fp_template.id,
155-
}
156-
)
157-
cls._create_xml_id(cls.fp_template_account)
158-
cls.tax_group = cls.env["account.tax.group"].create({"name": "Test tax group"})
159-
cls.account_tag_1 = cls.env["account.account.tag"].create(
160-
{"name": "Test account tag 1"}
161-
)
162-
cls.account_tag_2 = cls.env["account.account.tag"].create(
163-
{"name": "Test account tag 2"}
164-
)
16520
cls.company = cls.env["res.company"].create(
16621
{
16722
"name": "Test account_chart_update company",
168-
"currency_id": cls.chart_template.currency_id.id,
169-
"country_id": cls.env.ref("base.es").id,
23+
"country_id": cls.env.ref("base.us").id,
17024
}
17125
)
172-
chart_by_company_user = cls.chart_template.with_company(cls.company)
173-
chart_by_company_user.try_loading()
174-
cls.tax = cls.env["account.tax"].search(
26+
template = cls.env["account.chart.template"]
27+
template.try_loading("generic_coa", cls.company)
28+
cls.chart_template_data = template._get_chart_template_data("generic_coa")
29+
# We delete the records so that we can later delete the linked data
30+
moves = cls.env["account.move"].search(
17531
[
176-
("name", "=", cls.tax_template.name),
17732
("company_id", "=", cls.company.id),
17833
]
17934
)
180-
cls.account = cls.env["account.account"].search(
181-
[
182-
("code", "=", cls.account_template.code),
183-
("company_id", "=", cls.company.id),
184-
]
185-
)
186-
cls.fp = cls.env["account.fiscal.position"].search(
187-
[("name", "=", cls.fp_template.name), ("company_id", "=", cls.company.id)]
188-
)
189-
# Prepare wizard values
35+
moves.filtered(lambda x: x.state == "posted").button_draft()
36+
moves.unlink()
37+
# Prepare wizard
19038
cls.wizard_obj = cls.env["wizard.update.charts.accounts"]
19139
cls.wizard_vals = {
19240
"company_id": cls.company.id,
193-
"chart_template_id": cls.chart_template.id,
41+
"chart_template": "generic_coa",
19442
"code_digits": 6,
195-
"lang": "en_US",
19643
}

0 commit comments

Comments
 (0)