diff --git a/odoo/modules/module.py b/odoo/modules/module.py index 1cbeb2842de1ac2bc4f34b5e17d2829e61774055..ac109c83e10ec77cf5a208560ea1be9ea73831bf 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -18,6 +18,8 @@ import odoo import odoo.tools as tools import odoo.release as release from odoo.tools import pycompat +from odoo.tools.misc import file_path + MANIFEST_NAMES = ('__manifest__.py', '__openerp__.py') README = ['README.rst', 'README.md', 'README.txt'] @@ -228,6 +230,8 @@ def get_module_path(module, downloaded=False, display_warning=True): path if nothing else is found. """ + if re.search(r"[\/\\]", module): + return False for adp in odoo.addons.__path__: files = [opj(adp, module, manifest) for manifest in MANIFEST_NAMES] +\ [opj(adp, module + '.zip')] @@ -281,19 +285,19 @@ def get_resource_path(module, *args): :rtype: str :return: absolute path to the resource - - TODO make it available inside on osv object (self.get_resource_path) """ - mod_path = get_module_path(module) - if not mod_path: + resource_path = opj(module, *args) + try: + return file_path(resource_path) + except (FileNotFoundError, ValueError): return False - return check_resource_path(mod_path, *args) def check_resource_path(mod_path, *args): resource_path = opj(mod_path, *args) - if os.path.exists(resource_path): - return resource_path - return False + try: + return file_path(resource_path) + except (FileNotFoundError, ValueError): + return False # backwards compatibility get_module_resource = get_resource_path