Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
10021 Visninger

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
Kassér
Forfatter Bedste svar

I found the answer:

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

Update, or:

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



Avatar
Kassér
Bedste svar

You can write, also this,

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

FOO

</t>

Avatar
Kassér
Forfatter

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 Besvarelser Visninger Aktivitet
0
mar. 24
3354
3
okt. 16
6992
1
dec. 23
26984
1
mar. 15
7907
3
sep. 24
46983