From e9859a097976613ff9cf8fd35854546794f6775a Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Fri, 17 Apr 2020 10:21:59 +0000 Subject: [FIX] module.py: Remove useless path initialization The `initialize_sys_path` is the function responsible of getting the custom Odoo import hooks to work, i.e. addons import via `import odoo.addons`. This function is called by some other module related functions to ensure the paths are correctly setup. We are confident it is useless to re-initialize the path in many places. The `load_openerp_module` function is called during server bootup by both `odoo-bin server` and `odoo-bin shell`, both command parse the configuration before starting the server which initialize the paths already. Most call to `get_module`, `get_module_path` and `get_resource_path` are done in models or controllers where a registry is setup already. There is one notable exception which is the subcommand discovery done during the bootup, for that specific case, we initialize the paths with a partially loaded configuration. closes odoo/odoo#49715 Task: 2200956 Signed-off-by: Raphael Collet (rco) --- odoo/cli/command.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'odoo/cli') diff --git a/odoo/cli/command.py b/odoo/cli/command.py index 1d28506fa0b..113c86d5631 100644 --- a/odoo/cli/command.py +++ b/odoo/cli/command.py @@ -5,7 +5,7 @@ import os from os.path import join as joinpath, isdir import odoo -from odoo.modules import get_modules, get_module_path +from odoo.modules import get_modules, get_module_path, initialize_sys_path commands = {} @@ -48,6 +48,7 @@ def main(): # Subcommand discovery if len(args) and not args[0].startswith("-"): logging.disable(logging.CRITICAL) + initialize_sys_path() for module in get_modules(): if isdir(joinpath(get_module_path(module), 'cli')): __import__('odoo.addons.' + module) -- cgit v1.2.3