diff --git a/module_change_auto_install/README.rst b/module_change_auto_install/README.rst new file mode 100644 index 00000000000..e650c809f18 --- /dev/null +++ b/module_change_auto_install/README.rst @@ -0,0 +1,8 @@ +=============================== +Change auto installable modules +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/module_change_auto_install/__init__.py b/module_change_auto_install/__init__.py new file mode 100644 index 00000000000..2e653d695c9 --- /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 00000000000..6a6220a2a16 --- /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": "14.0.1.0.1", + "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/patch.py b/module_change_auto_install/patch.py new file mode 100644 index 00000000000..9285ffddba8 --- /dev/null +++ b/module_change_auto_install/patch.py @@ -0,0 +1,40 @@ +# 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_information_from_description_file = ( + modules.module.load_information_from_description_file +) + + +def _overload_load_information_from_description_file(module, mod_path=None): + res = _original_load_information_from_description_file(module, mod_path=None) + auto_install = res.get("auto_install", False) + + modules_auto_install_enabled = config.get("modules_auto_install_enabled", []) + modules_auto_install_disabled = config.get("modules_auto_install_disabled", []) + + if module in modules_auto_install_disabled and auto_install: + _logger.info("Module '%s' has been marked as not auto installable." % module) + res["auto_install"] = False + + if module in modules_auto_install_enabled and not auto_install: + _logger.info("Module '%s' has been marked as auto installable." % module) + res["auto_install"] = True + + return res + + +def post_load(): + modules.module.load_information_from_description_file = ( + _overload_load_information_from_description_file + ) + modules.load_information_from_description_file = ( + _overload_load_information_from_description_file + ) diff --git a/module_change_auto_install/readme/CONFIGURE.rst b/module_change_auto_install/readme/CONFIGURE.rst new file mode 100644 index 00000000000..e766d4315d3 --- /dev/null +++ b/module_change_auto_install/readme/CONFIGURE.rst @@ -0,0 +1,33 @@ +* 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) diff --git a/module_change_auto_install/readme/CONTRIBUTORS.rst b/module_change_auto_install/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..9f76a75bc18 --- /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 00000000000..dbd184a2fed --- /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 00000000000..a2ee648d603 --- /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 00000000000..c7804edadb8 --- /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/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 00000000000..4d5125f29d9 --- /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 00000000000..28c57bb6403 --- /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, +)