Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
10023 Tampilan

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>

Avatar
Buang
Penulis Jawaban Terbai

I found the answer:

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

Update, or:

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



Avatar
Buang
Jawaban Terbai

You can write, also this,

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

FOO

</t>

Avatar
Buang
Penulis

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

Post Terkait Replies Tampilan Aktivitas
0
Mar 24
3354
3
Okt 16
6993
1
Des 23
26984
1
Mar 15
7907
3
Sep 24
46983