forked from OCA/server-tools
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1648 from OCA/18.0
Syncing from upstream OCA/server-tools (18.0)
- Loading branch information
Showing
20 changed files
with
1,020 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
=============================== | ||
Change auto installable modules | ||
=============================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:17cbf0571e6045cc19cebbcb57adeb91019ffff44dc0eb526943c78073453e3b | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/licence-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/18.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-18-0/server-tools-18-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=18.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_auto_install_disabled`` 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_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. 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 | ||
modules_auto_install_disabled = | ||
partner_autocomplete, | ||
iap, | ||
mail_bot | ||
modules_auto_install_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 | ||
modules_auto_install_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:%2018.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 <vincent.hatakeyama@xcg-consulting.fr> | ||
|
||
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/18.0/module_change_auto_install>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .patch import post_load |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "18.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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
13
module_change_auto_install/i18n/module_change_auto_install.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# 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 | ||
import os | ||
|
||
from odoo import modules | ||
from odoo.tools import config | ||
|
||
_logger = logging.getLogger(__name__) | ||
_original_load_manifest = modules.module.load_manifest | ||
|
||
|
||
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 | ||
modules_auto_install_enabled = | ||
web_responsive:web, | ||
base_technical_features:, | ||
point_of_sale:sale/purchase, | ||
account_usability | ||
>>> split_strip('modules_auto_install_enabled') | ||
{ | ||
'web_responsive': ['web'], | ||
'base_technical_features': [], | ||
'point_of_sale': ['sale', 'purchase'], | ||
'account_usability': False, | ||
} | ||
""" | ||
res = {} | ||
config_value = (config_value or "").strip(" ,") | ||
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 _overload_load_manifest(module, mod_path=None): | ||
res = _original_load_manifest(module, mod_path=None) | ||
auto_install = res.get("auto_install", False) | ||
|
||
modules_auto_install_enabled_dict = _get_modules_dict_auto_install_config( | ||
config.get( | ||
"modules_auto_install_enabled", | ||
os.environ.get("ODOO_MODULES_AUTO_INSTALL_ENABLED"), | ||
) | ||
) | ||
modules_auto_install_disabled_dict = _get_modules_dict_auto_install_config( | ||
config.get( | ||
"modules_auto_install_disabled", | ||
os.environ.get("ODOO_MODULES_AUTO_INSTALL_DISABLED"), | ||
) | ||
) | ||
|
||
if auto_install and module in modules_auto_install_disabled_dict.keys(): | ||
_logger.info(f"Module '{module}' has been marked as NOT auto installable.") | ||
res["auto_install"] = 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.") | ||
res["auto_install"] = set(res["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." | ||
) | ||
|
||
res["auto_install"] = set(specific_dependencies) | ||
|
||
return res | ||
|
||
|
||
def post_load(): | ||
_logger.info("Aplying patch module_change_auto_intall ...") | ||
modules.module.load_manifest = _overload_load_manifest | ||
modules.load_manifest = _overload_load_manifest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
Oops, something went wrong.