diff --git a/account_chart_update/README.rst b/account_chart_update/README.rst index a3c84e28d77..258a6887226 100644 --- a/account_chart_update/README.rst +++ b/account_chart_update/README.rst @@ -1,7 +1,3 @@ -.. image:: https://odoo-community.org/readme-banner-image - :target: https://odoo-community.org/get-involved?utm_source=readme - :alt: Odoo Community Association - =========================================================== Detect changes and update the Account Chart from a template =========================================================== @@ -17,7 +13,7 @@ Detect changes and update the Account Chart from a template .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :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 @@ -112,6 +108,7 @@ Contributors - Luis J. Salvatierra - Daniel Reis (dreis@opensourceintegrators.com) +- Joel Estrada (https://www.moduon.team/) Maintainers ----------- diff --git a/account_chart_update/readme/CONTRIBUTORS.md b/account_chart_update/readme/CONTRIBUTORS.md index 5ce87a5470f..cfbd96168dc 100644 --- a/account_chart_update/readme/CONTRIBUTORS.md +++ b/account_chart_update/readme/CONTRIBUTORS.md @@ -12,3 +12,4 @@ - [Factor Libre](https://factorlibre.com): - Luis J. Salvatierra - Daniel Reis (dreis@opensourceintegrators.com) +- Joel Estrada () \ No newline at end of file diff --git a/account_chart_update/static/description/index.html b/account_chart_update/static/description/index.html index b4488d96c2f..2618c9f019a 100644 --- a/account_chart_update/static/description/index.html +++ b/account_chart_update/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +Detect changes and update the Account Chart from a template -
+
+

Detect changes and update the Account Chart from a template

- - -Odoo Community Association - -
-

Detect changes and update the Account Chart from a template

-

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runboat

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.

@@ -402,7 +397,7 @@

Detect changes and update the Account Chart from a template

-

Usage

+

Usage

The wizard, accesible from Accounting > Settings > Update Chart Template, lets the user select what kind of objects must be checked/updated, and whether old records must be checked for changes and @@ -412,7 +407,7 @@

Usage

to exclude records individually.

-

Known issues / Roadmap

+

Known issues / Roadmap

  • Generate and update account reconcile models.
  • Generate XML-ID for fiscal position tax and account mapping lines.
  • @@ -422,7 +417,7 @@

    Known issues / Roadmap

-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub 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 @@ -430,9 +425,9 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Tecnativa
  • BCIM
  • @@ -440,7 +435,7 @@

    Authors

-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -476,6 +472,5 @@

Maintainers

-
diff --git a/account_chart_update/wizard/wizard_chart_update.py b/account_chart_update/wizard/wizard_chart_update.py index fb629531ea9..774e8bdc177 100644 --- a/account_chart_update/wizard/wizard_chart_update.py +++ b/account_chart_update/wizard/wizard_chart_update.py @@ -211,25 +211,42 @@ def _domain_per_name(self, name): ] def _domain_tax_group_field_ids(self): - return self._domain_per_name("account.tax.group") + return self._domain_per_name("account.tax.group") + [ + ("ttype", "!=", "one2many") + ] def _domain_tax_field_ids(self): - return self._domain_per_name("account.tax") + # Allow specific o2m fields critical for comparison + # (repartition_line_ids) but exclude other o2m + return self._domain_per_name("account.tax") + [ + "|", + ("ttype", "!=", "one2many"), + ( + "name", + "in", + [ + "repartition_line_ids", + ], + ), + ] def _domain_account_field_ids(self): - return self._domain_per_name("account.account") + return self._domain_per_name("account.account") + [("ttype", "!=", "one2many")] def _domain_account_group_field_ids(self): - return self._domain_per_name("account.group") + return self._domain_per_name("account.group") + [("ttype", "!=", "one2many")] def _domain_fp_field_ids(self): - return self._domain_per_name("account.fiscal.position") + return self._domain_per_name("account.fiscal.position") + [ + ("ttype", "!=", "one2many") + ] def _default_tax_group_field_ids(self): return [ (4, x.id) for x in self.env["ir.model.fields"].search( - self._domain_tax_group_field_ids() + [("ttype", "!=", "one2many")], + self._domain_tax_group_field_ids() + + self.get_uncheck_fields_domain("account.tax.group"), ) ] @@ -237,7 +254,8 @@ def _default_tax_field_ids(self): return [ (4, x.id) for x in self.env["ir.model.fields"].search( - self._domain_tax_field_ids() + [("ttype", "!=", "one2many")], + self._domain_tax_field_ids() + + self.get_uncheck_fields_domain("account.tax"), ) ] @@ -245,7 +263,8 @@ def _default_account_field_ids(self): return [ (4, x.id) for x in self.env["ir.model.fields"].search( - self._domain_account_field_ids() + [("ttype", "!=", "one2many")], + self._domain_account_field_ids() + + self.get_uncheck_fields_domain("account.account"), ) ] @@ -254,13 +273,17 @@ def _default_account_group_field_ids(self): (4, x.id) for x in self.env["ir.model.fields"].search( self._domain_account_group_field_ids() + + self.get_uncheck_fields_domain("account.group") ) ] def _default_fp_field_ids(self): return [ (4, x.id) - for x in self.env["ir.model.fields"].search(self._domain_fp_field_ids()) + for x in self.env["ir.model.fields"].search( + self._domain_fp_field_ids() + + self.get_uncheck_fields_domain("account.fiscal.position") + ) ] def _get_matching_ids(self, model_name, ordered_opts): @@ -494,22 +517,18 @@ def padded_code(self, code): def fields_to_ignore(self, name): """Get fields that will not be used when checking differences. - :param str template: A template record. :param str name: The name of the template model. :return set: Fields to ignore in diff. """ mail_thread_fields = set(self.env["mail.thread"]._fields) specials_mapping = { "account.tax.group": mail_thread_fields | {"sequence"}, - "account.tax": mail_thread_fields | {"children_tax_ids", "sequence"}, + "account.tax": mail_thread_fields | {"children_tax_ids"} | {"sequence"}, "account.account": mail_thread_fields | { "root_id", }, - "account.group": {"parent_id", "code_prefix_end"}, - "account.fiscal.position": { - "sequence", - }, + "account.group": {"parent_id"}, } specials = { "display_name", @@ -518,6 +537,22 @@ def fields_to_ignore(self, name): } | specials_mapping.get(name, set()) return set(models.MAGIC_COLUMNS) | specials + @api.model + def get_default_unchecked_fields(self, name): + """Get fields that should be unchecked by default for a given model. + + :param str name: The name of the template model. + :return set: Fields to uncheck by default. + """ + unchecked_mapping = { + "account.fiscal.position": {"sequence"}, + } + return unchecked_mapping.get(name, set()) + + def get_uncheck_fields_domain(self, name): + unchecked_fields = list(self.get_default_unchecked_fields(name)) + return [("name", "not in", unchecked_fields)] + @api.model def diff_fields(self, record_values, real): # noqa: C901 """Get fields that are different in record values and real records.