[FIX] import-hook: correctly import the server-wide-module (i.e

use the openerp.addons namespace), and correctly set the submodules in
sys.modules (instead of only the top-level package).

bzr revid: vmt@openerp.com-20120201152710-s7sxlgibwd3lwr5l
This commit is contained in:
Vo Minh Thu 2012-02-01 16:27:10 +01:00
parent 996578ed49
commit 084af04092
2 changed files with 4 additions and 1 deletions

View File

@ -243,7 +243,7 @@ if __name__ == "__main__":
for m in openerp.conf.server_wide_modules:
try:
__import__(m)
__import__('openerp.addons.' + m)
# Call any post_load hook.
info = openerp.modules.module.load_information_from_description_file(m)
if info['post_load']:

View File

@ -140,6 +140,9 @@ To import it, use `import openerp.addons.<module>.`.""" % (module_name, path))
mod = imp.load_module(module_name, f, path, descr)
if not is_shadowing:
sys.modules[module_part] = mod
for k in sys.modules.keys():
if k.startswith('openerp.addons.' + module_part):
sys.modules[k[len('openerp.addons.'):]] = sys.modules[k]
sys.modules['openerp.addons.' + module_part] = mod
return mod