Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
10183 Visualizzazioni

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
Abbandona
Autore Risposta migliore

I found the answer:

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

Update, or:

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



Avatar
Abbandona
Risposta migliore

You can write, also this,

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

FOO

</t>

Avatar
Abbandona
Autore

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

Post correlati Risposte Visualizzazioni Attività
0
mar 24
3467
3
ott 16
7104
1
dic 23
27146
1
mar 15
8059
3
set 24
47172