Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
10159 Vistas

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 Mejor respuesta

I found the answer:

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

Update, or:

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



Avatar
Descartar
Mejor respuesta

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

Publicaciones relacionadas Respuestas Vistas Actividad
0
mar 24
3464
3
oct 16
7097
1
dic 23
27132
1
mar 15
8047
3
sept 24
47160