Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
10018 มุมมอง

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)".

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 24
3354
3
ต.ค. 16
6989
1
ธ.ค. 23
26984
1
มี.ค. 15
7906
3
ก.ย. 24
46980