[FIX] base: avoid warning when computing desc of to_buy modules

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) <xdo@odoo.com>
This commit is contained in:
Xavier-Do
2020-08-21 16:07:00 +00:00
parent 1495065041
commit 4da3f9cf1c
3 changed files with 12 additions and 7 deletions
+4 -2
View File
@@ -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)
+1
View File
@@ -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,
+7 -5
View File
@@ -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