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

Do you know how to check whether the field exists (is defined in model) in the report template?

For example if field xxx is defined FOO is printed:

<t t-if="test(o.xxx)">FOO</t>

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

I found the answer:

<t t-if="'xxx' in o">FOO</t> 

Update, or:

<t t-if='o.get("xxx")'>FOO</t> 



아바타
취소
베스트 답변

You can write, also this,

<t t-if="o.xxx">

FOO

</t>

아바타
취소
작성자

This is not a good solution, if filed xxx not exists in model cause the error: ... object has no attribute 'xxx'" while evaluating.

You are right, I misunderstood the question.. I forgot to notice "field exists (is defined in model)".

관련 게시물 답글 화면 활동
0
3월 24
3356
3
10월 16
6993
1
12월 23
26987
1
3월 15
7907
3
9월 24
46986