diff --git a/account_chart_update_code_digits/README.rst b/account_chart_update_code_digits/README.rst new file mode 100644 index 00000000000..a6be5b633ba --- /dev/null +++ b/account_chart_update_code_digits/README.rst @@ -0,0 +1,126 @@ +================================ +Account Chart Update Code Digits +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:8496b47c44ab03d44f20c812451e8ec2ee8233139c39de45f030ca18a28faf79 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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 + :target: https://github.com/OCA/account-financial-tools/tree/18.0/account_chart_update_code_digits + :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-18-0/account-financial-tools-18-0-account_chart_update_code_digits + :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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of account_chart_update to make +possible modify the length of acccount codes when checking for updates +in the wizard. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +This module was developed to be able to modify the account length of the +account updater to eliminate detecting changes that are not actually +needed. + +Configuration +============= + +No configuration is needed. By default, the lenght of the account codes +is set from chart template. If the chart template hasn't length, then +“6” is set. + +To change the account code length: + +1. Go to *Accounting > Settings > Update Chart Template* +2. Modify the field ``Account Code Digits`` +3. Click on **Next** with the field ``Update accounts`` selected +4. Review the accounts to be updated +5. Click on **Create/Update** to apply the new code length to the + accounts + +Usage +===== + +The wizard, accessible from *Accounting > Settings > Update Chart +Template*, now displays the ``Account Code Digits`` field. + +The default is the length of each chart template but if modified, the +value is saved in a company field and becomes the default value. + +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Moduon + +Contributors +------------ + +- Joel Estrada (`Moduon `__) + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-u0f| image:: https://github.com/u0f.png?size=40px + :target: https://github.com/u0f + :alt: u0f +.. |maintainer-rafelbn| image:: https://github.com/rafelbn.png?size=40px + :target: https://github.com/rafelbn + :alt: rafelbn + +Current `maintainers `__: + +|maintainer-u0f| |maintainer-rafelbn| + +This module is part of the `OCA/account-financial-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_chart_update_code_digits/__init__.py b/account_chart_update_code_digits/__init__.py new file mode 100644 index 00000000000..aee8895e7a3 --- /dev/null +++ b/account_chart_update_code_digits/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/account_chart_update_code_digits/__manifest__.py b/account_chart_update_code_digits/__manifest__.py new file mode 100644 index 00000000000..782ad2633f0 --- /dev/null +++ b/account_chart_update_code_digits/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2025 Moduon Team S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) + +{ + "name": "Account Chart Update Code Digits", + "summary": "Modify account chart digits lenght", + "version": "18.0.1.0.0", + "development_status": "Alpha", + "category": "Accounting", + "website": "https://github.com/OCA/account-financial-tools", + "author": "Moduon, Odoo Community Association (OCA)", + "maintainers": ["u0f", "rafelbn"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "account_chart_update", + ], + "data": [ + "wizards/wizard_chart_update_view.xml", + ], +} diff --git a/account_chart_update_code_digits/i18n/account_chart_update_code_digits.pot b/account_chart_update_code_digits/i18n/account_chart_update_code_digits.pot new file mode 100644 index 00000000000..9fb85905fe1 --- /dev/null +++ b/account_chart_update_code_digits/i18n/account_chart_update_code_digits.pot @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_chart_update_code_digits +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-01-13 10:11+0000\n" +"PO-Revision-Date: 2026-01-13 10:11+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_chart_update_code_digits +#: model:ir.model.fields,field_description:account_chart_update_code_digits.field_res_company__account_code_digits +msgid "Account Code Digits" +msgstr "" + +#. module: account_chart_update_code_digits +#: model:ir.model.fields,field_description:account_chart_update_code_digits.field_wizard_update_charts_accounts__code_digits +msgid "Code Digits" +msgstr "" + +#. module: account_chart_update_code_digits +#: model:ir.model,name:account_chart_update_code_digits.model_res_company +msgid "Companies" +msgstr "" + +#. module: account_chart_update_code_digits +#. odoo-python +#: code:addons/account_chart_update_code_digits/wizards/wizard_chart_update.py:0 +msgid "" +"The following accounts could not be automatically updated to " +"%(digits)s digits because they are not created by the chart " +"of accounts template. Please update them manually: %(accounts)s" +msgstr "" + +#. module: account_chart_update_code_digits +#: model:ir.model,name:account_chart_update_code_digits.model_wizard_update_charts_accounts +msgid "Wizard Update Charts Accounts" +msgstr "" diff --git a/account_chart_update_code_digits/i18n/es.po b/account_chart_update_code_digits/i18n/es.po new file mode 100644 index 00000000000..0c98e5cd551 --- /dev/null +++ b/account_chart_update_code_digits/i18n/es.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_chart_update_code_digits +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-01-13 10:11+0000\n" +"PO-Revision-Date: 2026-01-13 10:15+0100\n" +"Last-Translator: Joel Estrada Castellano \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.6\n" + +#. module: account_chart_update_code_digits +#: model:ir.model.fields,field_description:account_chart_update_code_digits.field_res_company__account_code_digits +msgid "Account Code Digits" +msgstr "Dígitos del código de las cuentas contables" + +#. module: account_chart_update_code_digits +#: model:ir.model.fields,field_description:account_chart_update_code_digits.field_wizard_update_charts_accounts__code_digits +msgid "Code Digits" +msgstr "Dígitos del código de las cuentas contables" + +#. module: account_chart_update_code_digits +#: model:ir.model,name:account_chart_update_code_digits.model_res_company +msgid "Companies" +msgstr "Compañías" + +#. module: account_chart_update_code_digits +#. odoo-python +#: code:addons/account_chart_update_code_digits/wizards/wizard_chart_update.py:0 +msgid "" +"The following accounts could not be automatically updated to " +"%(digits)s digits because they are not created by the chart " +"of accounts template. Please update them manually: %(accounts)s" +msgstr "" +"Las siguientes cuentas no se han podido actualizar automáticamente a " +"%(digits)s dígitos porque no están creados en la plantilla " +"del plan contable. Por favor, actualícelas manualmente: %(accounts)s" + +#. module: account_chart_update_code_digits +#: model:ir.model,name:account_chart_update_code_digits.model_wizard_update_charts_accounts +msgid "Wizard Update Charts Accounts" +msgstr "Wizard Actualización Plan de Cuentas" diff --git a/account_chart_update_code_digits/models/__init__.py b/account_chart_update_code_digits/models/__init__.py new file mode 100644 index 00000000000..aff44f335ae --- /dev/null +++ b/account_chart_update_code_digits/models/__init__.py @@ -0,0 +1 @@ +from . import res_company diff --git a/account_chart_update_code_digits/models/res_company.py b/account_chart_update_code_digits/models/res_company.py new file mode 100644 index 00000000000..bcead0db8ed --- /dev/null +++ b/account_chart_update_code_digits/models/res_company.py @@ -0,0 +1,10 @@ +# Copyright 2025 Moduon Team S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + account_code_digits = fields.Integer() diff --git a/account_chart_update_code_digits/pyproject.toml b/account_chart_update_code_digits/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/account_chart_update_code_digits/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_chart_update_code_digits/readme/CONFIGURE.md b/account_chart_update_code_digits/readme/CONFIGURE.md new file mode 100644 index 00000000000..6c60b1d5eb0 --- /dev/null +++ b/account_chart_update_code_digits/readme/CONFIGURE.md @@ -0,0 +1,11 @@ +No configuration is needed. By default, the lenght of the account codes is set from chart template. +If the chart template hasn't length, then “6” is set. + +To change the account code length: + +1. Go to _Accounting > Settings > Update Chart Template_ +2. Modify the field `Account Code Digits` +3. Click on **Next** with the field `Update accounts` selected +4. Review the accounts to be updated +5. Click on **Create/Update** to apply the new code length to the accounts + diff --git a/account_chart_update_code_digits/readme/CONTEXT.md b/account_chart_update_code_digits/readme/CONTEXT.md new file mode 100644 index 00000000000..8b2f8a5efad --- /dev/null +++ b/account_chart_update_code_digits/readme/CONTEXT.md @@ -0,0 +1,2 @@ +This module was developed to be able to modify the account length of the account updater +to eliminate detecting changes that are not actually needed. diff --git a/account_chart_update_code_digits/readme/CONTRIBUTORS.md b/account_chart_update_code_digits/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..bec30ea3827 --- /dev/null +++ b/account_chart_update_code_digits/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Joel Estrada ([Moduon](https://www.moduon.team/)) diff --git a/account_chart_update_code_digits/readme/DESCRIPTION.md b/account_chart_update_code_digits/readme/DESCRIPTION.md new file mode 100644 index 00000000000..0c75eb777b3 --- /dev/null +++ b/account_chart_update_code_digits/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends the functionality of account_chart_update to make possible modify +the length of acccount codes when checking for updates in the wizard. diff --git a/account_chart_update_code_digits/readme/USAGE.md b/account_chart_update_code_digits/readme/USAGE.md new file mode 100644 index 00000000000..15dc9a9f3bf --- /dev/null +++ b/account_chart_update_code_digits/readme/USAGE.md @@ -0,0 +1,5 @@ +The wizard, accessible from _Accounting > Settings > Update Chart Template_, now +displays the `Account Code Digits` field. + +The default is the length of each chart template but if modified, +the value is saved in a company field and becomes the default value. \ No newline at end of file diff --git a/account_chart_update_code_digits/static/description/icon.png b/account_chart_update_code_digits/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/account_chart_update_code_digits/static/description/icon.png differ diff --git a/account_chart_update_code_digits/static/description/index.html b/account_chart_update_code_digits/static/description/index.html new file mode 100644 index 00000000000..0652d28dcba --- /dev/null +++ b/account_chart_update_code_digits/static/description/index.html @@ -0,0 +1,464 @@ + + + + + +Account Chart Update Code Digits + + + +
+

Account Chart Update Code Digits

+ + +

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

+

This module extends the functionality of account_chart_update to make +possible modify the length of acccount codes when checking for updates +in the wizard.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Use Cases / Context

+

This module was developed to be able to modify the account length of the +account updater to eliminate detecting changes that are not actually +needed.

+
+
+

Configuration

+

No configuration is needed. By default, the lenght of the account codes +is set from chart template. If the chart template hasn’t length, then +“6” is set.

+

To change the account code length:

+
    +
  1. Go to Accounting > Settings > Update Chart Template
  2. +
  3. Modify the field Account Code Digits
  4. +
  5. Click on Next with the field Update accounts selected
  6. +
  7. Review the accounts to be updated
  8. +
  9. Click on Create/Update to apply the new code length to the +accounts
  10. +
+
+
+

Usage

+

The wizard, accessible from Accounting > Settings > Update Chart +Template, now displays the Account Code Digits field.

+

The default is the length of each chart template but if modified, the +value is saved in a company field and becomes the default value.

+
+
+

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 +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Moduon
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainers:

+

u0f rafelbn

+

This module is part of the OCA/account-financial-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_chart_update_code_digits/tests/__init__.py b/account_chart_update_code_digits/tests/__init__.py new file mode 100644 index 00000000000..d74b9f7a146 --- /dev/null +++ b/account_chart_update_code_digits/tests/__init__.py @@ -0,0 +1 @@ +from . import test_wizard diff --git a/account_chart_update_code_digits/tests/test_wizard.py b/account_chart_update_code_digits/tests/test_wizard.py new file mode 100644 index 00000000000..15da93e10fa --- /dev/null +++ b/account_chart_update_code_digits/tests/test_wizard.py @@ -0,0 +1,31 @@ +from odoo.tests import tagged + +from odoo.addons.account_chart_update.tests.common import TestAccountChartUpdateCommon + + +@tagged("-at_install", "post_install") +class AccountChartUpdateWizardTest(TestAccountChartUpdateCommon): + def test_wizard(self): + """Test the wizard code_digits logics.""" + wizard = self.wizard_obj.with_company(self.company).create(self.wizard_vals) + self.assertEqual(wizard.company_id, self.company) + self.assertEqual(wizard.chart_template, "generic_coa") + # Verify code_digits is 6 when opening due to default number + wizard._onchage_chart_template() + self.assertEqual(self.company.account_code_digits, 0) + self.assertEqual(wizard.code_digits, 6) + # Change the code_digits to 10 + wizard.code_digits = 10 + wizard.action_find_records() + # Company code_digits are not changed till the accounts are modified + self.assertEqual(self.company.account_code_digits, 0) + wizard.action_update_records() + # When the accounts are updated, it change + self.assertEqual(self.company.account_code_digits, 10) + + wizard2 = self.wizard_obj.with_company(self.company).create(self.wizard_vals) + self.assertEqual(wizard2.company_id, self.company) + self.assertEqual(wizard2.chart_template, "generic_coa") + # Verify that code_digits is 10 when opening + wizard2._onchage_chart_template() + self.assertEqual(wizard2.code_digits, 10) diff --git a/account_chart_update_code_digits/wizards/__init__.py b/account_chart_update_code_digits/wizards/__init__.py new file mode 100644 index 00000000000..fbd95d57bd3 --- /dev/null +++ b/account_chart_update_code_digits/wizards/__init__.py @@ -0,0 +1 @@ +from . import wizard_chart_update diff --git a/account_chart_update_code_digits/wizards/wizard_chart_update.py b/account_chart_update_code_digits/wizards/wizard_chart_update.py new file mode 100644 index 00000000000..11f33c893e4 --- /dev/null +++ b/account_chart_update_code_digits/wizards/wizard_chart_update.py @@ -0,0 +1,59 @@ +# Copyright 2025 Moduon Team S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) +import logging + +from odoo import _, api, fields, models + +_logger = logging.getLogger(__name__) + + +class WizardUpdateChartsAccounts(models.TransientModel): + _inherit = "wizard.update.charts.accounts" + + code_digits = fields.Integer() + + @api.onchange("chart_template") + def _onchage_chart_template(self): + res = super()._onchage_chart_template() + self.code_digits = self.company_id.account_code_digits or self.code_digits + return res + + def _update_accounts(self, t_data): + res = super()._update_accounts(t_data) + self.company_id.account_code_digits = self.code_digits + return res + + @api.model + def diff_fields(self, record_values, real): + res = super().diff_fields(record_values, real) + if real._name != "account.account" or "code" not in record_values: + return res + ignore = self.fields_to_ignore(real._name) + if "code" in ignore: + return res + record_values["code"] = self.padded_code(record_values["code"]) + if record_values["code"] != real["code"]: + res["code"] = record_values["code"] + return res + + def _update_accounts(self, t_data): + res = super()._update_accounts(t_data) + self.company_id.account_code_digits = self.code_digits + + failed_accounts = ( + self.env["account.account"] + .search([("company_ids", "in", self.company_id.id)]) + .filtered(lambda a: len(a.code) != self.code_digits) + ) + if failed_accounts: + account_names = ", ".join(failed_accounts.mapped("name")) + msg = _( + "The following accounts could not be automatically updated to " + "%(digits)s digits because they are not created by the chart " + "of accounts template. Please update them manually: %(accounts)s", + digits=self.code_digits, + accounts=account_names, + ) + _logger.info(msg) + self.log = f"{msg}\n{self.log}" if self.log else msg + return res diff --git a/account_chart_update_code_digits/wizards/wizard_chart_update_view.xml b/account_chart_update_code_digits/wizards/wizard_chart_update_view.xml new file mode 100644 index 00000000000..134e87cff32 --- /dev/null +++ b/account_chart_update_code_digits/wizards/wizard_chart_update_view.xml @@ -0,0 +1,13 @@ + + + + Show code_digits in chart update wizard + wizard.update.charts.accounts + + + + 0 + + + +