Skip to Content
Menú
This question has been flagged
2 Respostes
10114 Vistes

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
Descartar
Autor Best Answer

I found the answer:

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

Update, or:

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



Avatar
Descartar
Best Answer

You can write, also this,

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

FOO

</t>

Avatar
Descartar
Autor

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 Respostes Vistes Activitat
0
de març 24
3395
3
d’oct. 16
7049
1
de des. 23
27062
1
de març 15
7975
3
de set. 24
47048