Skip to content

Commit b8c7cf2

Browse files
committed
[ADD] new module module_change_auto_install to configure auto installable modules by configuration
1 parent 0d65b2e commit b8c7cf2

File tree

9 files changed

+123
-0
lines changed

9 files changed

+123
-0
lines changed

module_change_auto_install/README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
===============================
2+
Change auto installable modules
3+
===============================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .patch import post_load
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
{
6+
"name": "Change auto installable modules",
7+
"summary": "Customize auto installables modules by configuration",
8+
"version": "14.0.1.0.1",
9+
"category": "Tools",
10+
"maintainers": ["legalsylvain"],
11+
"author": "GRAP, Odoo Community Association (OCA)",
12+
"website": "https://github.com/OCA/server-tools",
13+
"installable": True,
14+
"depends": ["base"],
15+
"post_load": "post_load",
16+
"license": "AGPL-3",
17+
}

module_change_auto_install/patch.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
import logging
6+
7+
from odoo import modules
8+
from odoo.tools import config
9+
10+
_logger = logging.getLogger(__name__)
11+
_original_load_information_from_description_file = (
12+
modules.module.load_information_from_description_file
13+
)
14+
15+
16+
def _overload_load_information_from_description_file(module, mod_path=None):
17+
res = _original_load_information_from_description_file(module, mod_path=None)
18+
auto_install = res.get("auto_install", False)
19+
20+
modules_auto_install_enabled = config.get("modules_auto_install_enabled", [])
21+
modules_auto_install_disabled = config.get("modules_auto_install_disabled", [])
22+
23+
if module in modules_auto_install_disabled and auto_install:
24+
_logger.info("Module '%s' has been marked as not auto installable." % module)
25+
res["auto_install"] = False
26+
27+
if module in modules_auto_install_enabled and not auto_install:
28+
_logger.info("Module '%s' has been marked as auto installable." % module)
29+
res["auto_install"] = True
30+
31+
return res
32+
33+
34+
def post_load():
35+
modules.module.load_information_from_description_file = (
36+
_overload_load_information_from_description_file
37+
)
38+
modules.load_information_from_description_file = (
39+
_overload_load_information_from_description_file
40+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
* Edit your ``odoo.cfg`` configuration file:
2+
3+
* Add the module ``module_change_auto_install`` in the ``server_wide_modules`` list.
4+
5+
* (optional) Add a new entry ``modules_auto_install_disabled`` to mark
6+
a list of modules as NOT auto installable.
7+
8+
* (optional) Add a new entry ``modules_auto_install_enabled`` to mark
9+
a list of modules as auto installable. This feature can be usefull for companies
10+
that are hosting a lot of Odoo instances for many customers, and want some modules
11+
to be always installed.
12+
13+
**Typical Settings**
14+
15+
.. code-block:: shell
16+
17+
server_wide_modules = web,module_change_auto_install
18+
19+
modules_auto_install_disabled = partner_autocomplete,iap,mail_bot,account_edi,account_edi_facturx,account_edi_ubl
20+
21+
modules_auto_install_enabled = web_responsive,web_no_bubble,base_technical_features,disable_odoo_online,account_menu
22+
23+
Run your instance and check logs. Modules that has been altered should be present in your log, at the load of your instance:
24+
25+
.. code-block:: shell
26+
27+
INFO db_name odoo.addons.module_change_auto_install.patch: Module 'iap' has been marked as not auto installable.
28+
INFO db_name odoo.addons.module_change_auto_install.patch: Module 'mail_bot' has been marked as not auto installable.
29+
INFO db_name odoo.addons.module_change_auto_install.patch: Module 'partner_autocomplete' has been marked as not auto installable.
30+
INFO db_name odoo.addons.module_change_auto_install.patch: Module 'account_edi' has been marked as not auto installable.
31+
INFO db_name odoo.addons.module_change_auto_install.patch: Module 'account_edi_facturx' has been marked as not auto installable.
32+
INFO db_name odoo.addons.module_change_auto_install.patch: Module 'account_edi_ubl' has been marked as not auto installable.
33+
INFO db_name odoo.modules.loading: 42 modules loaded in 0.32s, 0 queries (+0 extra)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Sylvain LE GAL <https://twitter.com/legalsylvain>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
In odoo, by default some modules are marked as auto installable
2+
by the ``auto_install`` key present in the manifest.
3+
4+
* This feature is very useful for "glue" modules that allow two modules to work together.
5+
(A typical example is ``sale_stock`` which allows ``sale`` and ``stock`` modules to work together).
6+
7+
* However, Odoo SA also marks some modules as auto installable, even though
8+
this is not technically required. This can happen
9+
for modules the company wants to promote like ``iap``,
10+
modules with a big wow effect like ``partner_autocomplete``,
11+
or some modules they consider useful by default like ``account_edi``.
12+
See the discussion: https://github.com/odoo/odoo/issues/71190
13+
14+
This module allows to change by configuration, the list of auto installable modules,
15+
adding or removing some modules to auto install.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
If you upgrade your odoo Instance from a major version to another,
2+
using the OCA Free Software project "OpenUpgrade", you can also use
3+
this module during the upgrade process, to avoid the installation of
4+
useless new modules.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
You don't have to install this module. To make the features working :
2+
3+
* make the module ``module_change_auto_install`` available in your addons path
4+
* update your ``odoo.cfg`` following the "Configure" section

0 commit comments

Comments
 (0)