Skip to content

Commit

Permalink
[ADD] new module module_change_auto_install to configure auto install…
Browse files Browse the repository at this point in the history
…able modules by configuration
  • Loading branch information
legalsylvain committed Oct 13, 2022
1 parent 0d65b2e commit b8c7cf2
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 0 deletions.
8 changes: 8 additions & 0 deletions module_change_auto_install/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
===============================
Change auto installable modules
===============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1 change: 1 addition & 0 deletions module_change_auto_install/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .patch import post_load
17 changes: 17 additions & 0 deletions module_change_auto_install/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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",
}
40 changes: 40 additions & 0 deletions module_change_auto_install/patch.py
Original file line number Diff line number Diff line change
@@ -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
)
33 changes: 33 additions & 0 deletions module_change_auto_install/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions module_change_auto_install/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
15 changes: 15 additions & 0 deletions module_change_auto_install/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions module_change_auto_install/readme/DEVELOP.rst
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions module_change_auto_install/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b8c7cf2

Please sign in to comment.