Openerp 7.0 中 server->openerp->modules->module.py 的 AddonsImportHook class 中有这样一个方法:
def find_module(self, module_name, package_path): module_parts = module_name.split(‘.‘) if len(module_parts) == 3 and module_name.startswith(‘openerp.addons.‘): return self # We act as a loader too.
# TODO list of loadable modules can be cached instead of always # calling get_module_path(). if len(module_parts) == 1 and \ get_module_path(module_parts[0], display_warning=False): try: # 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>.`.""" % (module_name, path)) return except ImportError, e: # Using `import <module_name>` instead of # `import openerp.addons.<module_name>` is ugly but not harmful # and kept for backward compatibility. return self # We act as a loader too.
而在8.0中这个方法是这样的:
def find_module(self, module_name, package_path): module_parts = module_name.split(‘.‘) if len(module_parts) == 3 and module_name.startswith(‘openerp.addons.‘): return self # We act as a loader too.