Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
10033 Weergaven

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
Annuleer
Auteur Beste antwoord

I found the answer:

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

Update, or:

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



Avatar
Annuleer
Beste antwoord

You can write, also this,

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

FOO

</t>

Avatar
Annuleer
Auteur

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

Gerelateerde posts Antwoorden Weergaven Activiteit
0
mrt. 24
3356
3
okt. 16
6994
1
dec. 23
26989
1
mrt. 15
7910
3
sep. 24
46989