Search code examples
odooodoo-13odoo-website

Is using Javascript in odoo.fields.HTML possible?


I want to integrate Adobe Captivate Content (Export: index.html, along with src-folder) into ODOO Community Edition v13 e-Learning Module (website_slides).

The slide.slide model already offers slide_type 'webpage' alongside the field 'html_content'. The field 'html_content' is of type odoo.fields.HTML. To get the requirement stated above to work, I need to embed Javascript in the given html_content. It seems like the JS-scripts are not working. I also tried with a simple Hello World script.

Can someone help?

Best regards, Lars


Solution

  • I found the solution already.

    Looking at odoo/fields.py -> class Html, you can see that by default the given value is being sanitized using odoo/tools/mail.py -> html_sanitize(), which removes the HTML-Elements in 'tags_to_kill'. 'tags_to_kill' also contains "script".

    After overriding html_content in slide.slide with the following, the Javascript-code is being executed:

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