Skip to content

Commit

Permalink
[MIG] account_chart_update: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-cort-s73 committed Feb 27, 2025
1 parent 6b72249 commit e3c1a1d
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 75 deletions.
58 changes: 29 additions & 29 deletions account_chart_update/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Detect changes and update the Account Chart from a template
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-tools/tree/17.0/account_chart_update
:target: https://github.com/OCA/account-financial-tools/tree/18.0/account_chart_update
:alt: OCA/account-financial-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-tools-17-0/account-financial-tools-17-0-account_chart_update
:target: https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-0-account_chart_update
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -34,12 +34,12 @@ on the chart template.

The wizard:

- Allows the user to compare a chart and a template showing differences
on accounts, taxes, tax codes and fiscal positions.
- It may create the new account, taxes, tax codes and fiscal positions
detected on the template.
- It can also update (overwrite) the accounts, taxes, tax codes and
fiscal positions that got modified on the template.
- Allows the user to compare a chart and a template showing differences
on accounts, taxes, tax codes and fiscal positions.
- It may create the new account, taxes, tax codes and fiscal positions
detected on the template.
- It can also update (overwrite) the accounts, taxes, tax codes and
fiscal positions that got modified on the template.

**Table of contents**

Expand All @@ -61,19 +61,19 @@ to exclude records individually.
Known issues / Roadmap
======================

- Generate and update account reconcile models.
- Generate XML-ID for fiscal position tax and account mapping lines.
- Allow to select independently operations to perform (create, update,
deactivate).
- Detect fiscal positions to deactivate?
- Generate and update account reconcile models.
- Generate XML-ID for fiscal position tax and account mapping lines.
- Allow to select independently operations to perform (create, update,
deactivate).
- Detect fiscal positions to deactivate?

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_chart_update%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_chart_update%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -90,23 +90,23 @@ Authors
Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:
- `Tecnativa <https://www.tecnativa.com>`__:

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

- Jacques-Etienne Baudoux <je@bcim.be>
- Sylvain Van Hoof <sylvain@okia.be>
- Nacho Muñoz <nacmuro@gmail.com>
- Alberto Martín - Guadaltech <alberto.martin@guadaltech.es>
- Fernando La Chica - GreenIce <fernandolachica@gmail.com>
- Jairo Llopis (https://www.moduon.team/)
- `Factor Libre <https://factorlibre.com>`__:
- Jacques-Etienne Baudoux <je@bcim.be>
- Sylvain Van Hoof <sylvain@okia.be>
- Nacho Muñoz <nacmuro@gmail.com>
- Alberto Martín - Guadaltech <alberto.martin@guadaltech.es>
- Fernando La Chica - GreenIce <fernandolachica@gmail.com>
- Jairo Llopis (https://www.moduon.team/)
- `Factor Libre <https://factorlibre.com>`__:

- Luis J. Salvatierra
- Luis J. Salvatierra

- Daniel Reis (dreis@opensourceintegrators.com)
- Daniel Reis (dreis@opensourceintegrators.com)

Maintainers
-----------
Expand All @@ -121,6 +121,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/17.0/account_chart_update>`_ project on GitHub.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/18.0/account_chart_update>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion account_chart_update/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"name": "Detect changes and update the Account Chart from a template",
"summary": "Wizard to update a company's account chart from a template",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Tecnativa, BCIM, Okia, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"depends": ["account"],
Expand Down
6 changes: 3 additions & 3 deletions account_chart_update/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Detect changes and update the Account Chart from a template</h
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4b9ad640a2561ddbe28d1e7f433424bd1d430e783546e974aac1a84f8f33e1da
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/17.0/account_chart_update"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-17-0/account-financial-tools-17-0-account_chart_update"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/18.0/account_chart_update"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-0-account_chart_update"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This is a pretty useful tool to update Odoo installations after tax
reforms on the official charts of accounts, or to apply fixes performed
on the chart template.</p>
Expand Down Expand Up @@ -421,7 +421,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_chart_update%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_chart_update%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -465,7 +465,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/17.0/account_chart_update">OCA/account-financial-tools</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/18.0/account_chart_update">OCA/account-financial-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions account_chart_update/tests/test_account_chart_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def test_chart_update_01(self):
self.assertFalse(wizard.fiscal_position_ids)
# We delete the existing records so that they appear "to be created".
domain = [("company_id", "=", self.company.id)]
ip = self.env["ir.property"].sudo()
self.env["account.tax"].search(domain).unlink()
# ip = self.env["ir.property"].sudo()
# self.env["account.tax"].search(domain).unlink()
accounts = self.env["account.account"].search(domain)
values = [f"account.account,{a_id}" for a_id in accounts.ids]
ip.search([("value_reference", "in", values)]).unlink()
# values = [f"account.account,{a_id}" for a_id in accounts.ids]
# ip.search([("value_reference", "in", values)]).unlink()
journals = self.env["account.journal"].search(domain)
values = [f"account.journal,{j_id}" for j_id in journals.ids]
ip.search([("value_reference", "in", values)]).unlink()
# values = [f"account.journal,{j_id}" for j_id in journals.ids]
# ip.search([("value_reference", "in", values)]).unlink()
journals.unlink()
accounts.unlink()
self.env["account.fiscal.position"].search(domain).unlink()
Expand Down
40 changes: 20 additions & 20 deletions account_chart_update/wizard/wizard_chart_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,24 +338,23 @@ def _get_chart_template_data(self):
"account.fiscal.position": self.update_fiscal_position,
}
langs = self.env["res.lang"].search([])
for m_name in model_mapping.keys():
if not model_mapping[m_name]:
for m_name, _key in model_mapping.items():
if not m_name:
continue
for _xmlid, r_data in t_data[m_name].items():
if "__translation_module__" in r_data:
for f_name in list(r_data["__translation_module__"].keys()):
for lang in langs:
field_translation = (
chart_template_model._get_field_translation(
r_data, f_name, lang.code
)
)
short_lang = lang.code.split("_")[0]
key_lang = f"{f_name}@{short_lang}"
if field_translation:
r_data[key_lang] = field_translation
else:
r_data[key_lang] = r_data[f_name]
if "__translation_module__" not in r_data:
continue
for f_name in list(r_data["__translation_module__"].keys()):
for lang in langs:
field_translation = chart_template_model._get_field_translation(
r_data, f_name, lang.code
)
short_lang = lang.code.split("_")[0]
key_lang = f"{f_name}@{short_lang}"
if field_translation:
r_data[key_lang] = field_translation
else:
r_data[key_lang] = r_data[f_name]
return t_data

def action_find_records(self):
Expand Down Expand Up @@ -467,8 +466,8 @@ def diff_fields(self, record_values, real): # noqa: C901
field = fields_by_key[key]
record_value, real_value = record_values[key], real[key]
if real._name == "account.account" and key == "code":
record_value = self.padded_code(record_value)
real_value = self.padded_code(real_value)
record_value = self.padded_code(str(record_value))
real_value = self.padded_code(str(real_value))
# Field ttype conditions
if field.ttype == "many2many":
if isinstance(record_value, str):
Expand Down Expand Up @@ -821,7 +820,8 @@ def _load_data(self, model, data):
if isinstance(xml_id, int):
record = self.env[model].browse(xml_id)
else:
xml_id = f"{('account.' + str(self.company_id.id) + '_') if '.' not in xml_id else ''}{xml_id}"
prefix = f"account.{self.company_id.id}_" if "." not in xml_id else ""
xml_id = f"{prefix}{xml_id}"
record = self.env.ref(xml_id)
# Updatr translation vals
for lang in langs:
Expand All @@ -848,7 +848,7 @@ def _update_taxes(self, t_data):
tax = wiz_tax.update_tax_id
if wiz_tax.type == "deleted":
tax.active = False
_logger.info(_("Deactivated tax %s."), "'%s'" % tax.name)
_logger.info(_("Deactivated tax %s."), tax.name)
continue
xml_id = wiz_tax.xml_id
key = tax.id or xml_id
Expand Down
Loading

0 comments on commit e3c1a1d

Please sign in to comment.