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

[ADD] new module module_change_auto_install to configure auto installable modules by configuration #2091

Merged
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
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
6 changes: 6 additions & 0 deletions setup/module_change_auto_install/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)