콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
480 화면

Hello,

In Odoo 16, I have an Html field.

I would like to add data containing html tags from a python function, like in this example:

html_field = fields.html()

def update_html_field(self):
self.html_field += '<div>First div</div><div>Second div</div>'

Actually, the html tags (in this example, the '<div>' tags) are not interpreted as html tags, and the view is not correct, showing the text '<div>First div</div><div>Second div</div>'.

Thanks in advace,

Boris



아바타
취소
작성자 베스트 답변

I find the solution.

In Odoo 16, the fields.Html are markupsafe.Markup objects and not str objects.

Then, the solution is:
self.html_field += markupsafe.Markup('<div>First div</div><div>Second div</div>')
아바타
취소