From 3bb659689031124243b1e6f0ddb3c377b5d3d2d9 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 9 Feb 2012 17:30:16 +0100 Subject: [PATCH] [IMP] import hook: allow and give precedence to our own modules. This should be reverted for 6.2 when the openerp.addons namespace will be the only option. lp bug: https://launchpad.net/bugs/929466 fixed bzr revid: vmt@openerp.com-20120209163016-1wiw1xsrppumjvfl --- openerp/modules/module.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/openerp/modules/module.py b/openerp/modules/module.py index 6238aadaed0..bb3f45705c7 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -101,10 +101,9 @@ class AddonsImportHook(object): # Check if the bare module name clashes with another module. f, path, descr = imp.find_module(module_parts[0]) _logger.warning(""" -Ambiguous import: the OpenERP module `%s` is shadowed by another -module (available at %s). -To import it, use `import openerp.addons..`.""" % (module_name, path)) - return +Ambiguous import: the OpenERP module `%s` is shadowing another +module (available at %s).""" % (module_name, path)) + return self # We act as a loader too. except ImportError, e: # Using `import ` instead of # `import openerp.addons.` is ugly but not harmful @@ -137,7 +136,7 @@ To import it, use `import openerp.addons..`.""" % (module_name, path)) # Note: we don't support circular import. f, path, descr = imp.find_module(module_part, ad_paths) mod = imp.load_module('openerp.addons.' + module_part, f, path, descr) - if not is_shadowing: + if is_shadowing or not is_shadowing: # == if True, but keep the defined variable. sys.modules[module_part] = mod for k in sys.modules.keys(): if k.startswith('openerp.addons.' + module_part):