Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3393126
[ADD] new module module_change_auto_install to configure auto install…
legalsylvain May 25, 2021
7a41943
[UPD] Update module_change_auto_install.pot
oca-travis May 25, 2021
1814950
[UPD] README.rst
OCA-git-bot May 25, 2021
45c9abb
[ADD] icon.png
OCA-git-bot May 25, 2021
969999b
[FIX] module_change_auto_install: Split string sep by comma
moylop260 May 26, 2021
323ca86
module_change_auto_install 14.0.1.0.2
OCA-git-bot May 26, 2021
3fbb005
[FIX] module_change_auto_install : auto_install is now a set of depen…
legalsylvain Dec 22, 2021
ea7668d
module_change_auto_install 14.0.1.0.3
OCA-git-bot Dec 22, 2021
9fcfcd6
Added translation using Weblate (Catalan)
ofonseca-pyming Feb 14, 2022
7151c48
[MIG] module_change_auto_install: Migration to 15.0
kafai-lam Sep 19, 2022
96b9b41
[PORT] module_change_auto_install from 15.0 to 16.0
legalsylvain Oct 13, 2022
7a2c4e5
[UPD] Update module_change_auto_install.pot
Nov 8, 2022
91eb0fa
[UPD] README.rst
OCA-git-bot Nov 8, 2022
d13e74c
Update translation files
weblate Nov 8, 2022
3381637
[UPD] README.rst
OCA-git-bot Sep 3, 2023
2bacede
[IMP] module_change_auto_install: pre-commit stuff
rven Dec 6, 2023
491e4ad
[MIG] module_change_auto_install: Migration to 17.0
rven Dec 6, 2023
19d63fa
[UPD] Update module_change_auto_install.pot
Dec 9, 2023
18e053c
[BOT] post-merge updates
OCA-git-bot Dec 9, 2023
9f88a5c
[MIG] base_exception: Migration to 17.0
lef-adhoc Jan 16, 2024
640a52a
Added translation using Weblate (Italian)
mymage Feb 6, 2024
b9311ee
[FIX] *: Pre-commit fixes
pedrobaeza May 2, 2024
67a2ed6
[BOT] post-merge updates
OCA-git-bot May 2, 2024
35a7de6
[IMP] module_change_auto_install: also allow using environment variables
vincent-hatakeyama Jan 18, 2024
e6c2f2a
[BOT] post-merge updates
OCA-git-bot Jun 28, 2024
4eb682f
[IMP] module_change_auto_install: pre-commit stuff
lembregtse Oct 8, 2024
e707a76
[MIG] module_change_auto_install: Migration to 18.0
lembregtse Oct 8, 2024
23d0773
[UPD] Update module_change_auto_install.pot
Oct 25, 2024
26ddb64
[BOT] post-merge updates
OCA-git-bot Oct 25, 2024
e06a17c
Fix patch message
jeroenev Nov 12, 2024
2d2272e
[BOT] post-merge updates
OCA-git-bot Nov 12, 2024
ed30136
[FIX] module_change_auto_install : prevent to crash if a module is no…
legalsylvain May 15, 2025
a8859a1
[BOT] post-merge updates
OCA-git-bot May 16, 2025
2a39874
[FIX] module_change_auto_install: AttributeError: 'NoneType' object h…
rven Jun 11, 2025
bf6b607
[BOT] post-merge updates
OCA-git-bot Jun 11, 2025
494a9b7
[MIG] module_change_auto_install: Migration to 19.0
rven Sep 22, 2025
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
209 changes: 209 additions & 0 deletions module_change_auto_install/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===============================
Change auto installable modules
===============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:162ad195483bc21079128fc8075e1cf29eba3e177cffd0fbfa8d42f28a27ceab
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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/19.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-19-0/server-tools-19-0-module_change_auto_install
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=19.0
:alt: Try me on Runboat

|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
- either update your ``odoo.cfg`` or set the environment variables
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_disabled`` beneath a new section
``[module_change_auto_install]`` to mark a list of modules as NOT
auto installable. The environment variable
``ODOO_MODULES_AUTO_INSTALL_DISABLED`` can also be set.
- (optional) Add a new entry ``modules_enabled`` beneath a new section
``[module_change_auto_install]`` 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. The environment variable
``ODOO_MODULES_AUTO_INSTALL_ENABLED`` can also be set.

The values in the configuration file takes precedence over the
environment variable values.

**Typical Settings**

.. code:: cfg

server_wide_modules = web,module_change_auto_install

[module_change_auto_install]
modules_disabled =
partner_autocomplete,
iap,
mail_bot

modules_enabled =
web_responsive:web,
base_technical_features,
disable_odoo_online,
account_usability

When using environment variables, the same configuration is:

.. code:: shell

export ODOO_MODULES_AUTO_INSTALL_DISABLED=partner_autocomplete,iap,mail_bot
export ODOO_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:: 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:: cfg

[module_change_auto_install]
modules_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.

When using environment variables, the same configuration is:

.. code:: shell

export ODOO_MODULES_AUTO_INSTALL_ENABLED=account_usability,web_responsive:web,base_technical_features:,point_of_sale:sale/purchase

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 <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20module_change_auto_install%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* GRAP

Contributors
------------

- Sylvain LE GAL <https://twitter.com/legalsylvain>

- XCG Consulting, part of `Orbeet <https://orbeet.io/>`__:

- Vincent Hatakeyama <[email protected]>

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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-legalsylvain|

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/19.0/module_change_auto_install>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
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": "19.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",
}
Empty file.
Empty file.
14 changes: 14 additions & 0 deletions module_change_auto_install/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: it\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"
13 changes: 13 additions & 0 deletions module_change_auto_install/i18n/module_change_auto_install.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.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"
127 changes: 127 additions & 0 deletions module_change_auto_install/patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# 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 configparser
import logging
import os

from odoo.modules.module import Manifest
from odoo.tools import config

_logger = logging.getLogger(__name__)
_original_init = Manifest.__init__


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
[module_change_auto_install]
modules_enabled =
web_responsive:web,
base_technical_features:,
point_of_sale:sale/purchase,
account_usability

>>> split_strip('modules_enabled')
{
'web_responsive': ['web'],
'base_technical_features': [],
'point_of_sale': ['sale', 'purchase'],
'account_usability': False,
}


"""
res = {}
config_value = (config_value or "").strip(" ,")
if config_value:
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 _get_modules_auto_install_enabled_dict():
return _get_modules_dict_auto_install_config(
config.get(
"module_change_auto_install.modules_enabled",
os.environ.get("ODOO_MODULES_AUTO_INSTALL_ENABLED"),
)
)


def _get_modules_auto_install_disabled_dict():
return _get_modules_dict_auto_install_config(
config.get(
"module_change_auto_install.modules_disabled",
os.environ.get("ODOO_MODULES_AUTO_INSTALL_DISABLED"),
)
)


def _get_auto_install_flag(self):
modules_auto_install_enabled_dict = _get_modules_auto_install_enabled_dict()
modules_auto_install_disabled_dict = _get_modules_auto_install_disabled_dict()
auto_install = self._Manifest__manifest_cached["auto_install"]
module = self.name

if auto_install and module in modules_auto_install_disabled_dict.keys():
_logger.info(f"Module '{module}' has been marked as NOT auto installable.")
return False

if not auto_install and module in modules_auto_install_enabled_dict.keys():
specific_dependencies = modules_auto_install_enabled_dict.get(module)
if isinstance(specific_dependencies, bool):
# Classical case
_logger.info(f"Module '{module}' has been marked as auto installable.")
return set(self._Manifest__manifest_cached["depends"])
else:
if specific_dependencies:
_logger.info(
"Module '{}' has been marked as auto installable if '{}' "
"are installed".format(module, ",".join(specific_dependencies))
)
else:
_logger.info(
f"Module '{module}' has been marked as auto installable in "
f"ALL CASES."
)

return set(specific_dependencies)
return auto_install


def _patched_init(self, *, path: str, manifest_content: dict):
_original_init(self, path=path, manifest_content=manifest_content)
# Post-process before cached_property kicks in
self.auto_install = _get_auto_install_flag(self)
if "auto_install" in self._Manifest__manifest_cached:
self._Manifest__manifest_cached["auto_install"] = self.auto_install


def _load_module_change_auto_install_options(rcfile):
"""Load custom [module_change_auto_install] section into config."""
cp = configparser.ConfigParser()
cp.read([rcfile])

if cp.has_section("module_change_auto_install"):
for key, value in cp.items("module_change_auto_install"):
# Store with prefix to avoid collisions
config[f"module_change_auto_install.{key}"] = value
_logger.debug("Loaded custom option %s=%s", key, value)


def post_load():
_logger.info("Applying patch module_change_auto_install ...")
Manifest.__init__ = _patched_init
rcfile = config.get("config")
if rcfile:
_load_module_change_auto_install_options(rcfile)
3 changes: 3 additions & 0 deletions module_change_auto_install/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Loading
Loading