diff --git a/account_group_disable_adapt_methods/README.rst b/account_group_disable_adapt_methods/README.rst new file mode 100644 index 0000000..7601af7 --- /dev/null +++ b/account_group_disable_adapt_methods/README.rst @@ -0,0 +1,104 @@ +=================================== +Account Group Disable Adapt Methods +=================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:cc75e6f9ad8cd5edc5dce3d2d8b99e9b91b4efddb724f29d70c29a70dbde0273 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/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-Escodoo%2Faccount--addons-lightgray.png?logo=github + :target: https://github.com/Escodoo/account-addons/tree/14.0/account_group_disable_adapt_methods + :alt: Escodoo/account-addons + +|badge1| |badge2| |badge3| + +This module disables the execution of the adapt methods that are executed in the write and create methods of the account.group model. This is justified in cases of mass update of account.group since the execution of these methods makes the process very time-consuming. + +.. code-block:: python + + # Original Methods + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if 'code_prefix_start' in vals and not vals.get('code_prefix_end'): + vals['code_prefix_end'] = vals['code_prefix_start'] + res_ids = super(AccountGroup, self).create(vals_list) + res_ids._adapt_accounts_for_account_groups() + res_ids._adapt_parent_account_group() + return res_ids + + def write(self, vals): + res = super(AccountGroup, self).write(vals) + if 'code_prefix_start' in vals or 'code_prefix_end' in vals: + self._adapt_accounts_for_account_groups() + self._adapt_parent_account_group() + return res + + + # New Methods + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if 'code_prefix_start' in vals and not vals.get('code_prefix_end'): + vals['code_prefix_end'] = vals['code_prefix_start'] + return super(AccountGroupInherit, self).create(vals_list) + + def write(self, vals): + return super(AccountGroupInherit, self).write(vals) + +In addition, an action is implemented to execute the adapt methods by account group or groups. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Install this module. +#. Update account.group data +#. After updating the data, it is possible to select the account groups that will be updated and click on the actions button and execute the "Run Adapt Methods" action so that the adapt methods are executed. +#. After executing the adapt methods of all necessary groups, it is recommended to uninstall this module and only reinstall it again in a major update of account.group. + +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 +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* `Escodoo `_: + + * Marcel Savegnago + +Maintainers +~~~~~~~~~~~ + +This module is part of the `Escodoo/account-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/account_group_disable_adapt_methods/__init__.py b/account_group_disable_adapt_methods/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/account_group_disable_adapt_methods/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_group_disable_adapt_methods/__manifest__.py b/account_group_disable_adapt_methods/__manifest__.py new file mode 100644 index 0000000..05cf3dd --- /dev/null +++ b/account_group_disable_adapt_methods/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2023 - TODAY, Escodoo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Account Group Disable Adapt Methods", + "summary": """ + Account Group Disable Adapt Methods""", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "Escodoo", + "website": "https://github.com/Escodoo/account-addons", + "depends": [ + "account", + ], + "data": [ + "views/account_group.xml", + ], + "demo": [], +} diff --git a/account_group_disable_adapt_methods/models/__init__.py b/account_group_disable_adapt_methods/models/__init__.py new file mode 100644 index 0000000..28c53ed --- /dev/null +++ b/account_group_disable_adapt_methods/models/__init__.py @@ -0,0 +1 @@ +from . import account_group diff --git a/account_group_disable_adapt_methods/models/account_group.py b/account_group_disable_adapt_methods/models/account_group.py new file mode 100644 index 0000000..6887789 --- /dev/null +++ b/account_group_disable_adapt_methods/models/account_group.py @@ -0,0 +1,22 @@ +# Copyright 2023 - TODAY, Marcel Savegnago +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + +from odoo.addons.account.models.account_account import ( + AccountGroup as AccountGroupInherit, +) + + +class AccountGroup(models.Model): + _inherit = "account.group" + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if "code_prefix_start" in vals and not vals.get("code_prefix_end"): + vals["code_prefix_end"] = vals["code_prefix_start"] + return super(AccountGroupInherit, self).create(vals_list) + + def write(self, vals): + return super(AccountGroupInherit, self).write(vals) diff --git a/account_group_disable_adapt_methods/readme/CONTRIBUTORS.rst b/account_group_disable_adapt_methods/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..ae453a6 --- /dev/null +++ b/account_group_disable_adapt_methods/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Escodoo `_: + + * Marcel Savegnago diff --git a/account_group_disable_adapt_methods/readme/DESCRIPTION.rst b/account_group_disable_adapt_methods/readme/DESCRIPTION.rst new file mode 100644 index 0000000..31557b9 --- /dev/null +++ b/account_group_disable_adapt_methods/readme/DESCRIPTION.rst @@ -0,0 +1,35 @@ +This module disables the execution of the adapt methods that are executed in the write and create methods of the account.group model. This is justified in cases of mass update of account.group since the execution of these methods makes the process very time-consuming. + +.. code-block:: python + + # Original Methods + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if 'code_prefix_start' in vals and not vals.get('code_prefix_end'): + vals['code_prefix_end'] = vals['code_prefix_start'] + res_ids = super(AccountGroup, self).create(vals_list) + res_ids._adapt_accounts_for_account_groups() + res_ids._adapt_parent_account_group() + return res_ids + + def write(self, vals): + res = super(AccountGroup, self).write(vals) + if 'code_prefix_start' in vals or 'code_prefix_end' in vals: + self._adapt_accounts_for_account_groups() + self._adapt_parent_account_group() + return res + + + # New Methods + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if 'code_prefix_start' in vals and not vals.get('code_prefix_end'): + vals['code_prefix_end'] = vals['code_prefix_start'] + return super(AccountGroupInherit, self).create(vals_list) + + def write(self, vals): + return super(AccountGroupInherit, self).write(vals) + +In addition, an action is implemented to execute the adapt methods by account group or groups. diff --git a/account_group_disable_adapt_methods/readme/USAGE.rst b/account_group_disable_adapt_methods/readme/USAGE.rst new file mode 100644 index 0000000..85e564c --- /dev/null +++ b/account_group_disable_adapt_methods/readme/USAGE.rst @@ -0,0 +1,4 @@ +#. Install this module. +#. Update account.group data +#. After updating the data, it is possible to select the account groups that will be updated and click on the actions button and execute the "Run Adapt Methods" action so that the adapt methods are executed. +#. After executing the adapt methods of all necessary groups, it is recommended to uninstall this module and only reinstall it again in a major update of account.group. diff --git a/account_group_disable_adapt_methods/static/description/icon.png b/account_group_disable_adapt_methods/static/description/icon.png new file mode 100644 index 0000000..12ab005 Binary files /dev/null and b/account_group_disable_adapt_methods/static/description/icon.png differ diff --git a/account_group_disable_adapt_methods/static/description/index.html b/account_group_disable_adapt_methods/static/description/index.html new file mode 100644 index 0000000..6514ad3 --- /dev/null +++ b/account_group_disable_adapt_methods/static/description/index.html @@ -0,0 +1,461 @@ + + + + + + +Account Group Disable Adapt Methods + + + +
+

Account Group Disable Adapt Methods

+ + +

Beta License: AGPL-3 Escodoo/account-addons

+

This module disables the execution of the adapt methods that are executed in the write and create methods of the account.group model. This is justified in cases of mass update of account.group since the execution of these methods makes the process very time-consuming.

+
+# Original Methods
+@api.model_create_multi
+def create(self, vals_list):
+    for vals in vals_list:
+        if 'code_prefix_start' in vals and not vals.get('code_prefix_end'):
+            vals['code_prefix_end'] = vals['code_prefix_start']
+    res_ids = super(AccountGroup, self).create(vals_list)
+    res_ids._adapt_accounts_for_account_groups()
+    res_ids._adapt_parent_account_group()
+    return res_ids
+
+def write(self, vals):
+    res = super(AccountGroup, self).write(vals)
+    if 'code_prefix_start' in vals or 'code_prefix_end' in vals:
+        self._adapt_accounts_for_account_groups()
+        self._adapt_parent_account_group()
+    return res
+
+
+# New Methods
+@api.model_create_multi
+def create(self, vals_list):
+    for vals in vals_list:
+        if 'code_prefix_start' in vals and not vals.get('code_prefix_end'):
+            vals['code_prefix_end'] = vals['code_prefix_start']
+    return super(AccountGroupInherit, self).create(vals_list)
+
+def write(self, vals):
+    return super(AccountGroupInherit, self).write(vals)
+
+

In addition, an action is implemented to execute the adapt methods by account group or groups.

+

Table of contents

+ +
+

Usage

+
    +
  1. Install this module.
  2. +
  3. Update account.group data
  4. +
  5. After updating the data, it is possible to select the account groups that will be updated and click on the actions button and execute the “Run Adapt Methods” action so that the adapt methods are executed.
  6. +
  7. After executing the adapt methods of all necessary groups, it is recommended to uninstall this module and only reinstall it again in a major update of account.group.
  8. +
+
+
+

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

+
    +
  • Escodoo
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the Escodoo/account-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/account_group_disable_adapt_methods/views/account_group.xml b/account_group_disable_adapt_methods/views/account_group.xml new file mode 100644 index 0000000..2a18dea --- /dev/null +++ b/account_group_disable_adapt_methods/views/account_group.xml @@ -0,0 +1,20 @@ + + + + + + + Run Adapt Methods + + + code + + if records: + records._adapt_accounts_for_account_groups() + records._adapt_parent_account_group() + + + + + diff --git a/setup/account_group_disable_adapt_methods/odoo/addons/account_group_disable_adapt_methods b/setup/account_group_disable_adapt_methods/odoo/addons/account_group_disable_adapt_methods new file mode 120000 index 0000000..532c465 --- /dev/null +++ b/setup/account_group_disable_adapt_methods/odoo/addons/account_group_disable_adapt_methods @@ -0,0 +1 @@ +../../../../account_group_disable_adapt_methods \ No newline at end of file diff --git a/setup/account_group_disable_adapt_methods/setup.py b/setup/account_group_disable_adapt_methods/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/account_group_disable_adapt_methods/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)