diff --git a/module_change_auto_install/README.rst b/module_change_auto_install/README.rst new file mode 100644 index 000000000..47e665c1a --- /dev/null +++ b/module_change_auto_install/README.rst @@ -0,0 +1,148 @@ +=============================== +Change auto installable modules +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-OCA%2Fserver--tools-lightgray.png?logo=github + :target: https://github.com/OCA/server-tools/tree/15.0/module_change_auto_install + :alt: OCA/server-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-tools-15-0/server-tools-15-0-module_change_auto_install + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/149/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +In odoo, by default some modules are marked as auto installable +by the ``auto_install`` key present in the manifest. + +* This feature is very useful for "glue" modules that allow two modules to work together. + (A typical example is ``sale_stock`` which allows ``sale`` and ``stock`` modules to work together). + +* However, Odoo SA also marks some modules as auto installable, even though + this is not technically required. This can happen + for modules the company wants to promote like ``iap``, + modules with a big wow effect like ``partner_autocomplete``, + or some modules they consider useful by default like ``account_edi``. + See the discussion: https://github.com/odoo/odoo/issues/71190 + +This module allows to change by configuration, the list of auto installable modules, +adding or removing some modules to auto install. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +You don't have to install this module. To make the features working : + +* make the module ``module_change_auto_install`` available in your addons path +* update your ``odoo.cfg`` following the "Configure" section + +Configuration +============= + +* Edit your ``odoo.cfg`` configuration file: + +* Add the module ``module_change_auto_install`` in the ``server_wide_modules`` list. + +* (optional) Add a new entry ``modules_auto_install_disabled`` to mark + a list of modules as NOT auto installable. + +* (optional) Add a new entry ``modules_auto_install_enabled`` to mark + a list of modules as auto installable. This feature can be usefull for companies + that are hosting a lot of Odoo instances for many customers, and want some modules + to be always installed. + +**Typical Settings** + +.. code-block:: shell + + server_wide_modules = web,module_change_auto_install + + modules_auto_install_disabled = partner_autocomplete,iap,mail_bot,account_edi,account_edi_facturx,account_edi_ubl + + modules_auto_install_enabled = web_responsive,web_no_bubble,base_technical_features,disable_odoo_online,account_menu + +Run your instance and check logs. Modules that has been altered should be present in your log, at the load of your instance: + +.. code-block:: shell + + INFO db_name odoo.addons.module_change_auto_install.patch: Module 'iap' has been marked as not auto installable. + INFO db_name odoo.addons.module_change_auto_install.patch: Module 'mail_bot' has been marked as not auto installable. + INFO db_name odoo.addons.module_change_auto_install.patch: Module 'partner_autocomplete' has been marked as not auto installable. + INFO db_name odoo.addons.module_change_auto_install.patch: Module 'account_edi' has been marked as not auto installable. + INFO db_name odoo.addons.module_change_auto_install.patch: Module 'account_edi_facturx' has been marked as not auto installable. + INFO db_name odoo.addons.module_change_auto_install.patch: Module 'account_edi_ubl' has been marked as not auto installable. + INFO db_name odoo.modules.loading: 42 modules loaded in 0.32s, 0 queries (+0 extra) + +Development +=========== + +If you upgrade your odoo Instance from a major version to another, +using the OCA Free Software project "OpenUpgrade", you can also use +this module during the upgrade process, to avoid the installation of +useless new modules. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* GRAP + +Contributors +~~~~~~~~~~~~ + +* Sylvain LE GAL + +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-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px + :target: https://github.com/legalsylvain + :alt: legalsylvain + +Current `maintainer `__: + +|maintainer-legalsylvain| + +This module is part of the `OCA/server-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/module_change_auto_install/__init__.py b/module_change_auto_install/__init__.py new file mode 100644 index 000000000..2e653d695 --- /dev/null +++ b/module_change_auto_install/__init__.py @@ -0,0 +1 @@ +from .patch import post_load diff --git a/module_change_auto_install/__manifest__.py b/module_change_auto_install/__manifest__.py new file mode 100644 index 000000000..c5e4106a4 --- /dev/null +++ b/module_change_auto_install/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Change auto installable modules", + "summary": "Customize auto installables modules by configuration", + "version": "16.0.1.0.0", + "category": "Tools", + "maintainers": ["legalsylvain"], + "author": "GRAP, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/server-tools", + "installable": True, + "depends": ["base"], + "post_load": "post_load", + "license": "AGPL-3", +} diff --git a/module_change_auto_install/i18n/ca.po b/module_change_auto_install/i18n/ca.po new file mode 100644 index 000000000..6ff2ef5f3 --- /dev/null +++ b/module_change_auto_install/i18n/ca.po @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" diff --git a/module_change_auto_install/i18n/fr.po b/module_change_auto_install/i18n/fr.po new file mode 100644 index 000000000..a07e4484b --- /dev/null +++ b/module_change_auto_install/i18n/fr.po @@ -0,0 +1,15 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-10-13 13:04+0000\n" +"PO-Revision-Date: 2022-10-13 13:04+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" diff --git a/module_change_auto_install/i18n/module_change_auto_install.pot b/module_change_auto_install/i18n/module_change_auto_install.pot new file mode 100644 index 000000000..a11baf5cd --- /dev/null +++ b/module_change_auto_install/i18n/module_change_auto_install.pot @@ -0,0 +1,13 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \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" diff --git a/module_change_auto_install/patch.py b/module_change_auto_install/patch.py new file mode 100644 index 000000000..b77b3ee14 --- /dev/null +++ b/module_change_auto_install/patch.py @@ -0,0 +1,91 @@ +# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import logging + +from odoo import modules +from odoo.tools import config + +_logger = logging.getLogger(__name__) +_original_load_manifest = modules.module.load_manifest + + +def _get_modules_dict_auto_install_config(config_value): + """Given a configuration parameter name, return a dict of + {module_name: modules_list or False} + + if the odoo.cfg file contains + + modules_auto_install_enabled = + web_responsive:web, + base_technical_features:, + point_of_sale:sale/purchase, + account_usability + + >>> split_strip('modules_auto_install_enabled') + { + 'web_responsive': ['web'], + 'base_technical_features': [], + 'point_of_sale': ['sale', 'purchase'], + 'account_usability': False, + } + + + """ + res = {} + config_value = (config_value or "").strip(" ,") + config_list = [x.strip() for x in config_value.split(",")] + for item in config_list: + if ":" in item: + res[item.split(":")[0]] = ( + item.split(":")[1] and item.split(":")[1].split("/") or [] + ) + else: + res[item] = True + return res + + +def _overload_load_manifest(module, mod_path=None): + + res = _original_load_manifest(module, mod_path=None) + auto_install = res.get("auto_install", False) + + modules_auto_install_enabled_dict = _get_modules_dict_auto_install_config( + config.get("modules_auto_install_enabled") + ) + modules_auto_install_disabled_dict = _get_modules_dict_auto_install_config( + config.get("modules_auto_install_disabled") + ) + + if auto_install and module in modules_auto_install_disabled_dict.keys(): + _logger.info("Module '%s' has been marked as NOT auto installable." % module) + res["auto_install"] = False + + if not auto_install and module in modules_auto_install_enabled_dict.keys(): + specific_dependencies = modules_auto_install_enabled_dict.get(module) + if type(specific_dependencies) is bool: + # Classical case + _logger.info("Module '%s' has been marked as auto installable." % module) + res["auto_install"] = set(res["depends"]) + else: + if specific_dependencies: + _logger.info( + "Module '%s' has been marked as auto installable if '%s' are installed" + % (module, ",".join(specific_dependencies)) + ) + else: + _logger.info( + "Module '%s' has been marked as auto installable in ALL CASES." + % module + ) + + res["auto_install"] = set(specific_dependencies) + + return res + + +def post_load(): + _logger.info("Aplying patch module_change_auto_intall ...") + modules.module.load_manifest = _overload_load_manifest + modules.load_manifest = _overload_load_manifest diff --git a/module_change_auto_install/readme/CONFIGURE.rst b/module_change_auto_install/readme/CONFIGURE.rst new file mode 100644 index 000000000..7bb8d37bd --- /dev/null +++ b/module_change_auto_install/readme/CONFIGURE.rst @@ -0,0 +1,59 @@ +* Edit your ``odoo.cfg`` configuration file: + +* Add the module ``module_change_auto_install`` in the ``server_wide_modules`` list. + +* (optional) Add a new entry ``modules_auto_install_disabled`` to mark + a list of modules as NOT auto installable. + +* (optional) Add a new entry ``modules_auto_install_enabled`` to mark + a list of modules as auto installable. This feature can be usefull for companies + that are hosting a lot of Odoo instances for many customers, and want some modules + to be always installed. + +**Typical Settings** + +.. code-block:: shell + + server_wide_modules = web,module_change_auto_install + + modules_auto_install_disabled = + partner_autocomplete, + iap, + mail_bot + + modules_auto_install_enabled = + web_responsive:web, + base_technical_features, + disable_odoo_online, + account_usability + +Run your instance and check logs. Modules that has been altered should be present in your log, at the load of your instance: + +.. code-block:: shell + + INFO db_name odoo.addons.module_change_auto_install.patch: Module 'iap' has been marked as NOT auto installable. + INFO db_name odoo.addons.module_change_auto_install.patch: Module 'mail_bot' has been marked as NOT auto installable. + INFO db_name odoo.addons.module_change_auto_install.patch: Module 'partner_autocomplete' has been marked as NOT auto installable. + INFO db_name odoo.modules.loading: 42 modules loaded in 0.32s, 0 queries (+0 extra) + +**Advanced Configuration Possibilities** + +if your ``odoo.cfg`` file contains the following configuration: + +.. code-block:: shell + + modules_auto_install_enabled = + account_usability, + web_responsive:web, + base_technical_features:, + point_of_sale:sale/purchase + +The behaviour will be the following: + +* ``account_usability`` module will be installed as soon as all the default dependencies are installed. (here ``account``) + +* ``web_responsive`` module will be installed as soon as ``web`` is installed. (Althought ``web_responsive`` depends on ``web`` and ``mail``) + +* ``base_technical_features`` will be ALWAYS installed + +* ``point_of_sale`` module will be installed as soon as ``sale`` and ``purchase`` module are installed. diff --git a/module_change_auto_install/readme/CONTRIBUTORS.rst b/module_change_auto_install/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9f76a75bc --- /dev/null +++ b/module_change_auto_install/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sylvain LE GAL diff --git a/module_change_auto_install/readme/DESCRIPTION.rst b/module_change_auto_install/readme/DESCRIPTION.rst new file mode 100644 index 000000000..dbd184a2f --- /dev/null +++ b/module_change_auto_install/readme/DESCRIPTION.rst @@ -0,0 +1,15 @@ +In odoo, by default some modules are marked as auto installable +by the ``auto_install`` key present in the manifest. + +* This feature is very useful for "glue" modules that allow two modules to work together. + (A typical example is ``sale_stock`` which allows ``sale`` and ``stock`` modules to work together). + +* However, Odoo SA also marks some modules as auto installable, even though + this is not technically required. This can happen + for modules the company wants to promote like ``iap``, + modules with a big wow effect like ``partner_autocomplete``, + or some modules they consider useful by default like ``account_edi``. + See the discussion: https://github.com/odoo/odoo/issues/71190 + +This module allows to change by configuration, the list of auto installable modules, +adding or removing some modules to auto install. diff --git a/module_change_auto_install/readme/DEVELOP.rst b/module_change_auto_install/readme/DEVELOP.rst new file mode 100644 index 000000000..a2ee648d6 --- /dev/null +++ b/module_change_auto_install/readme/DEVELOP.rst @@ -0,0 +1,4 @@ +If you upgrade your odoo Instance from a major version to another, +using the OCA Free Software project "OpenUpgrade", you can also use +this module during the upgrade process, to avoid the installation of +useless new modules. diff --git a/module_change_auto_install/readme/INSTALL.rst b/module_change_auto_install/readme/INSTALL.rst new file mode 100644 index 000000000..c7804edad --- /dev/null +++ b/module_change_auto_install/readme/INSTALL.rst @@ -0,0 +1,4 @@ +You don't have to install this module. To make the features working : + +* make the module ``module_change_auto_install`` available in your addons path +* update your ``odoo.cfg`` following the "Configure" section diff --git a/module_change_auto_install/static/description/icon.png b/module_change_auto_install/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/module_change_auto_install/static/description/icon.png differ diff --git a/module_change_auto_install/static/description/index.html b/module_change_auto_install/static/description/index.html new file mode 100644 index 000000000..0dbf4816e --- /dev/null +++ b/module_change_auto_install/static/description/index.html @@ -0,0 +1,483 @@ + + + + + + +Change auto installable modules + + + +
+

Change auto installable modules

+ + +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

+

In odoo, by default some modules are marked as auto installable +by the auto_install key present in the manifest.

+
    +
  • This feature is very useful for “glue” modules that allow two modules to work together. +(A typical example is sale_stock which allows sale and stock modules to work together).
  • +
  • However, Odoo SA also marks some modules as auto installable, even though +this is not technically required. This can happen +for modules the company wants to promote like iap, +modules with a big wow effect like partner_autocomplete, +or some modules they consider useful by default like account_edi. +See the discussion: https://github.com/odoo/odoo/issues/71190
  • +
+

This module allows to change by configuration, the list of auto installable modules, +adding or removing some modules to auto install.

+

Table of contents

+ +
+

Installation

+

You don’t have to install this module. To make the features working :

+
    +
  • make the module module_change_auto_install available in your addons path
  • +
  • update your odoo.cfg following the “Configure” section
  • +
+
+
+

Configuration

+
    +
  • Edit your odoo.cfg configuration file:
  • +
  • Add the module module_change_auto_install in the server_wide_modules list.
  • +
  • (optional) Add a new entry modules_auto_install_disabled to mark +a list of modules as NOT auto installable.
  • +
  • (optional) Add a new entry modules_auto_install_enabled to mark +a list of modules as auto installable. This feature can be usefull for companies +that are hosting a lot of Odoo instances for many customers, and want some modules +to be always installed.
  • +
+

Typical Settings

+
+server_wide_modules = web,module_change_auto_install
+
+modules_auto_install_disabled = partner_autocomplete,iap,mail_bot,account_edi,account_edi_facturx,account_edi_ubl
+
+modules_auto_install_enabled = web_responsive,web_no_bubble,base_technical_features,disable_odoo_online,account_menu
+
+

Run your instance and check logs. Modules that has been altered should be present in your log, at the load of your instance:

+
+INFO db_name odoo.addons.module_change_auto_install.patch: Module 'iap' has been marked as not auto installable.
+INFO db_name odoo.addons.module_change_auto_install.patch: Module 'mail_bot' has been marked as not auto installable.
+INFO db_name odoo.addons.module_change_auto_install.patch: Module 'partner_autocomplete' has been marked as not auto installable.
+INFO db_name odoo.addons.module_change_auto_install.patch: Module 'account_edi' has been marked as not auto installable.
+INFO db_name odoo.addons.module_change_auto_install.patch: Module 'account_edi_facturx' has been marked as not auto installable.
+INFO db_name odoo.addons.module_change_auto_install.patch: Module 'account_edi_ubl' has been marked as not auto installable.
+INFO db_name odoo.modules.loading: 42 modules loaded in 0.32s, 0 queries (+0 extra)
+
+
+
+

Development

+

If you upgrade your odoo Instance from a major version to another, +using the OCA Free Software project “OpenUpgrade”, you can also use +this module during the upgrade process, to avoid the installation of +useless new modules.

+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • GRAP
  • +
+
+ +
+

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 maintainer:

+

legalsylvain

+

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

+

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

+
+
+
+ + diff --git a/module_change_auto_install/tests/__init__.py b/module_change_auto_install/tests/__init__.py new file mode 100644 index 000000000..d9b96c4fa --- /dev/null +++ b/module_change_auto_install/tests/__init__.py @@ -0,0 +1 @@ +from . import test_module diff --git a/module_change_auto_install/tests/test_module.py b/module_change_auto_install/tests/test_module.py new file mode 100644 index 000000000..7302d0cb1 --- /dev/null +++ b/module_change_auto_install/tests/test_module.py @@ -0,0 +1,30 @@ +# Copyright 2015-2017 Camptocamp SA +# Copyright 2020 Onestein () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + +from odoo.addons.module_change_auto_install.patch import ( + _get_modules_dict_auto_install_config, +) + +# from ..models.base import disable_changeset + + +class TestModule(TransactionCase): + + _EXPECTED_RESULTS = { + "web_responsive": {"web_responsive": True}, + "sale, purchase,": {"sale": True, "purchase": True}, + "web_responsive:web,base_technical_features:," + "point_of_sale:sale/purchase,account_usability": { + "web_responsive": ["web"], + "base_technical_features": [], + "point_of_sale": ["sale", "purchase"], + "account_usability": True, + }, + } + + def test_config_parsing(self): + for k, v in self._EXPECTED_RESULTS.items(): + self.assertEqual(_get_modules_dict_auto_install_config(k), v) diff --git a/setup/module_change_auto_install/odoo/addons/module_change_auto_install b/setup/module_change_auto_install/odoo/addons/module_change_auto_install new file mode 120000 index 000000000..4d5125f29 --- /dev/null +++ b/setup/module_change_auto_install/odoo/addons/module_change_auto_install @@ -0,0 +1 @@ +../../../../module_change_auto_install \ No newline at end of file diff --git a/setup/module_change_auto_install/setup.py b/setup/module_change_auto_install/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/module_change_auto_install/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)