Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][ADD] account_group_disable_adapt_methods: add new module #65

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions account_group_disable_adapt_methods/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/Escodoo/account-addons/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/Escodoo/account-addons/issues/new?body=module:%20account_group_disable_adapt_methods%0Aversion:%2014.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.

Credits
=======

Authors
~~~~~~~

* Escodoo

Contributors
~~~~~~~~~~~~

* `Escodoo <https://www.escodoo.com.br>`_:

* Marcel Savegnago <[email protected]>

Maintainers
~~~~~~~~~~~

This module is part of the `Escodoo/account-addons <https://github.com/Escodoo/account-addons/tree/14.0/account_group_disable_adapt_methods>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions account_group_disable_adapt_methods/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions account_group_disable_adapt_methods/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": [],
}
1 change: 1 addition & 0 deletions account_group_disable_adapt_methods/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_group
22 changes: 22 additions & 0 deletions account_group_disable_adapt_methods/models/account_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 - TODAY, Marcel Savegnago <[email protected]>
# 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)
3 changes: 3 additions & 0 deletions account_group_disable_adapt_methods/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Escodoo <https://www.escodoo.com.br>`_:

* Marcel Savegnago <[email protected]>
35 changes: 35 additions & 0 deletions account_group_disable_adapt_methods/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions account_group_disable_adapt_methods/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading