是否可以在odoo.fields.HTML中使用Javascript?

问题描述

我想将Adobe Captivate Content(出口:index.html,以及src-folder)集成到ODOO Community Edition v13电子学习模块(website_slides)中。

slide.slide模型已经在字段“ html_content”旁边提供了slide_type“网页”。 字段“ html_content”的类型为odoo.fields.HTML。为了使上述要求生效,我需要在给定的html_content中嵌入Javascript。似乎JS脚本无法正常工作。我还尝试了一个简单的Hello World脚本。

有人可以帮忙吗?

最好的问候, 拉斯

解决方法

我已经找到了解决方法。

看一下odoo/fields.py-> Html类,您可以看到默认情况下使用odoo/tools/mail.py-> html_sanitize()对给定值进行了清理,这将删除'tags_to_kill'中的HTML元素。 “ tags_to_kill”还包含“脚本”。

在使用以下代码覆盖slide.slide中的html_content之后,正在执行Javascript代码:

html_content = fields.Html(
   sanitize=False,sanitize_tags=False,sanitize_attributes=False)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...