From 110770b7c1c01bcd6136bc3b602032cfa7979422 Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Fri, 21 Oct 2022 12:43:37 +0000 Subject: [PATCH] [REM] core: openerp.addons alias and legacy ad_path Part-of: odoo/odoo#98138 --- odoo/modules/module.py | 64 ------------------------------------------ 1 file changed, 64 deletions(-) diff --git a/odoo/modules/module.py b/odoo/modules/module.py index d1740f7d045..fa63efbfcfe 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -60,71 +60,9 @@ _DEFAULT_MANIFEST = { _logger = logging.getLogger(__name__) -# addons path as a list -# ad_paths is a deprecated alias, please use odoo.addons.__path__ -@tools.lazy -def ad_paths(): - warnings.warn( - '"odoo.modules.module.ad_paths" is a deprecated proxy to ' - '"odoo.addons.__path__".', DeprecationWarning, stacklevel=2) - return odoo.addons.__path__ - # Modules already loaded loaded = [] -class AddonsHook(object): - """ Makes modules accessible through openerp.addons.* """ - - def find_module(self, name, path=None): - if name.startswith('openerp.addons.') and name.count('.') == 2: - warnings.warn( - '"openerp.addons" is a deprecated alias to "odoo.addons".', - DeprecationWarning, stacklevel=2) - return self - - def load_module(self, name): - assert name not in sys.modules - - odoo_name = re.sub(r'^openerp.addons.(\w+)$', r'odoo.addons.\g<1>', name) - - odoo_module = sys.modules.get(odoo_name) - if not odoo_module: - odoo_module = importlib.import_module(odoo_name) - - sys.modules[name] = odoo_module - - return odoo_module - -class OdooHook(object): - """ Makes odoo package also available as openerp """ - - def find_module(self, name, path=None): - # openerp.addons. should already be matched by AddonsHook, - # only framework and subdirectories of modules should match - if re.match(r'^openerp\b', name): - warnings.warn( - 'openerp is a deprecated alias to odoo.', - DeprecationWarning, stacklevel=2) - return self - - def load_module(self, name): - assert name not in sys.modules - - canonical = re.sub(r'^openerp(.*)', r'odoo\g<1>', name) - - if canonical in sys.modules: - mod = sys.modules[canonical] - else: - # probable failure: canonical execution calling old naming -> corecursion - mod = importlib.import_module(canonical) - - # just set the original module at the new location. Don't proxy, - # it breaks *-import (unless you can find how `from a import *` lists - # what's supposed to be imported by `*`, and manage to override it) - sys.modules[name] = mod - - return sys.modules[name] - class UpgradeHook(object): """Makes the legacy `migrations` package being `odoo.upgrade`""" @@ -191,8 +129,6 @@ def initialize_sys_path(): # hook deprecated module alias from openerp to odoo and "crm"-like to odoo.addons if not getattr(initialize_sys_path, 'called', False): # only initialize once sys.meta_path.insert(0, UpgradeHook()) - sys.meta_path.insert(0, OdooHook()) - sys.meta_path.insert(0, AddonsHook()) initialize_sys_path.called = True