diff --git a/app_base_chinese/__manifest__.py b/app_base_chinese/__manifest__.py index 6ae7fa38..05aa5e8c 100644 --- a/app_base_chinese/__manifest__.py +++ b/app_base_chinese/__manifest__.py @@ -79,6 +79,7 @@ 'data/product_pricelist_data.xml', 'data/stock_location_data.xml', 'data/sales_team_data.xml', + 'views/ir_module_module_views.xml', ], 'assets': { 'web.assets_backend': [ diff --git a/app_base_chinese/models/__init__.py b/app_base_chinese/models/__init__.py index ae2ddbc9..72104a3e 100644 --- a/app_base_chinese/models/__init__.py +++ b/app_base_chinese/models/__init__.py @@ -6,6 +6,6 @@ from . import res_currency from . import product_category from . import stock_location from . import account_tax_group - +from . import ir_module_module diff --git a/app_base_chinese/models/ir_module_module.py b/app_base_chinese/models/ir_module_module.py new file mode 100644 index 00000000..00e54235 --- /dev/null +++ b/app_base_chinese/models/ir_module_module.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +import logging +import lxml.html +from odoo import api, fields, models, modules, tools, _ + +_logger = logging.getLogger(__name__) + + +class Module(models.Model): + _inherit = "ir.module.module" + + description_html_cn = fields.Html('Description HTML CN', compute='_get_desc_cn') + + @api.depends('name', 'description') + def _get_desc_cn(self): + for module in self: + 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_cn.html') + else: + module.description_html_cn = False + if module_path and path: + with tools.file_open(path, 'rb') as desc_file: + doc = desc_file.read() + html = lxml.html.document_fromstring(doc) + for element, attribute, link, pos in html.iterlinks(): + if element.get('src') and not '//' in element.get('src') and not 'static/' in element.get('src'): + element.set('src', "/%s/static/description/%s" % (module.name, element.get('src'))) + module.description_html_cn = tools.html_sanitize(lxml.html.tostring(html)) + else: + module.description_html_cn = False diff --git a/app_base_chinese/views/ir_module_module_views.xml b/app_base_chinese/views/ir_module_module_views.xml new file mode 100644 index 00000000..264b81fa --- /dev/null +++ b/app_base_chinese/views/ir_module_module_views.xml @@ -0,0 +1,13 @@ + + + + app.base.chinese.module.module.form + ir.module.module + + + + + + + + \ No newline at end of file