From 4da3f9cf1c967eafd16dab7d5d4e5beb100fa1b7 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Fri, 21 Aug 2020 15:05:39 +0000 Subject: [PATCH] [FIX] base: avoid warning when computing desc of to_buy modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit post upgrade tests will trigger 'module not found' warning when testing modules views because of 'fake' modules without real file path. closes odoo/odoo#56335 Signed-off-by: Xavier Dollé (xdo) --- odoo/addons/base/models/ir_module.py | 6 ++++-- odoo/modules/__init__.py | 1 + odoo/modules/module.py | 12 +++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py index 57cbe796014..35d7bdd6313 100644 --- a/odoo/addons/base/models/ir_module.py +++ b/odoo/addons/base/models/ir_module.py @@ -177,8 +177,10 @@ class Module(models.Model): if not module.name: module.description_html = False continue - path = modules.get_module_resource(module.name, 'static/description/index.html') - if path: + module_path = modules.get_module_path(module.name, display_warning=False) # avoid to log warning for fake community module + if module_path: + path = modules.check_resource_path(module_path, 'static/description/index.html') + if module_path and path: with tools.file_open(path, 'rb') as desc_file: doc = desc_file.read() html = lxml.html.document_fromstring(doc) diff --git a/odoo/modules/__init__.py b/odoo/modules/__init__.py index b223df99280..3a754a4e171 100644 --- a/odoo/modules/__init__.py +++ b/odoo/modules/__init__.py @@ -17,6 +17,7 @@ from odoo.modules.module import ( get_modules_with_version, get_resource_from_path, get_resource_path, + check_resource_path, initialize_sys_path, load_information_from_description_file, load_openerp_module, diff --git a/odoo/modules/module.py b/odoo/modules/module.py index 6b7065a05ad..992fcf7b073 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -191,12 +191,14 @@ def get_resource_path(module, *args): TODO make it available inside on osv object (self.get_resource_path) """ mod_path = get_module_path(module) - if not mod_path: return False + if not mod_path: + 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.isdir(mod_path): - # the module is a directory - ignore zip behavior - if os.path.exists(resource_path): - return resource_path + if os.path.exists(resource_path): + return resource_path return False # backwards compatibility