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/modules/module.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'odoo/modules/module.py') diff --git a/odoo/modules/module.py b/odoo/modules/module.py index 61117965b0f..14c9d229b40 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -148,7 +148,6 @@ def get_module_path(module, downloaded=False, display_warning=True): path if nothing else is found. """ - initialize_sys_path() for adp in odoo.addons.__path__: files = [opj(adp, module, manifest) for manifest in MANIFEST_NAMES] +\ [opj(adp, module + '.zip')] @@ -364,7 +363,6 @@ def load_openerp_module(module_name): if module_name in loaded: return - initialize_sys_path() try: __import__('odoo.addons.' + module_name) @@ -404,7 +402,6 @@ def get_modules(): ] plist = [] - initialize_sys_path() for ad in odoo.addons.__path__: plist.extend(listdir(ad)) return list(set(plist)) -- cgit v1.2.3