-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[ADD] new module module_change_auto_install to configure auto installable modules by configuration #2091
Conversation
I prefer to set auto_install=False in OCB instead of this, as this module should be installed/present, and it can be too late for avoiding the auto-installing. |
Hi @pedrobaeza. Thanks for your quick review !
Your proposal presents some limitations IMO :
Didn't understood that point. Could you elaborate ? |
2d8d24e
to
87bd7ed
Compare
I mean that when you setup the module with those that you don't want, they are already populated in your DB. |
Maybe we should set this module as auto_install=True :) :) :) |
87bd7ed
to
df8f7ad
Compare
Well, if you use this module on a existing database, it will not uninstall undesired modules (that is quite safe). If you create a database with the correct setting in your You don't have to install this module. it just has to be present in your addons path, and mentionned in the Is it OK for you, regarding this point ? |
Yeah, thanks for the extra explanations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review
00b5dc0
to
002a03e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @legalsylvain
I think the current way will apply the patch even if this module is not installed.
What about using a post_load
way?
So, only if you have installed this module the patch will be apply
Hi @moylop260. Thanks for your review.
So I don't think your proposal is a valid alternative and I don't think it will work. Feel free to make a test if you're not agree. I'll test your proposal with pleasure. kind regards. |
You are right! I just realized that Odoo~14.0 is not pre-loading all the modules early even if it has a BTW I tested the hook and it is working in the same way (using load parameter or installed) Check the following patch I just applied: diff --git a/module_change_auto_install/__init__.py b/module_change_auto_install/__init__.py
index b946c62..2e653d6 100644
--- a/module_change_auto_install/__init__.py
+++ b/module_change_auto_install/__init__.py
@@ -1 +1 @@
-from . import patch
+from .patch import post_load
diff --git a/module_change_auto_install/__manifest__.py b/module_change_auto_install/__manifest__.py
index 7408083..268bb92 100644
--- a/module_change_auto_install/__manifest__.py
+++ b/module_change_auto_install/__manifest__.py
@@ -13,4 +13,5 @@
"installable": True,
"depends": ["base"],
"license": "AGPL-3",
+ "post_load": "post_load",
}
diff --git a/module_change_auto_install/patch.py b/module_change_auto_install/patch.py
index 861a12d..ce7962f 100644
--- a/module_change_auto_install/patch.py
+++ b/module_change_auto_install/patch.py
@@ -30,10 +30,11 @@ def _overload_load_information_from_description_file(module, mod_path=None):
return res
-
+def post_load():
+ _logger.warning("modules.module.load_information_from_description_file patched apply")
-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
-)
+ )
+ 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 And the following tests: It is because the hook is loaded only after to import the module: There is not real advantages using Do you think we should let it ready to be compatible for previous versions with minimal changes for backport? |
AFAIK, since v12 the |
Hi @moylop260. Thanks for your answer.
Nice ! I didn't know how So,
I will 2 / 3 extra tests, but if all is ok, I think that we can implement the @StefanRijnhart : maybe that thread could interest you, with your "ample experience with dirty monkeypatching in Odoo" ;-) kind regards. |
002a03e
to
5bf1227
Compare
Hi @moylop260. After extra tests both implementation are working correctly. (also tested both on V12). |
…able modules by configuration
5bf1227
to
3224468
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thank you again
/ocabot merge nobump |
This PR looks fantastic, let's merge it! |
Congratulations, your PR was merged at 4624667. Thanks a lot for contributing to OCA. ❤️ |
Hum... seing some recent PR in Odoo core like this one, odoo/odoo#75178 I think that this module will be ported in V15+ ;-) |
DESCRIPTION
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 allowssale
andstock
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 likepartner_autocomplete
, or some modules they consider useful by default likeaccount_edi
. See the discussion: [] account_edi: Why account_edi is autoinstall? odoo/odoo#71190This module allows to change by configuration, the list of auto installable modules, adding or removing some modules to
auto install.
CONFIGURE
Edit your
odoo.cfg
configuration file:Add the module
module_change_auto_install
in theserver_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. Thisfeature 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
Run your instance and check logs. Modules that has been altered should be present in your log, at the load of your instance:
INSTALL
You don't have to install this module. Just make it available in your addons path.