Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
10002 Vues

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
Ignorer
Auteur Meilleure réponse

I found the answer:

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

Update, or:

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



Avatar
Ignorer
Meilleure réponse

You can write, also this,

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

FOO

</t>

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

Publications associées Réponses Vues Activité
0
mars 24
3340
3
oct. 16
6977
1
déc. 23
26977
1
mars 15
7903
3
sept. 24
46973