Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
10026 Vizualizări

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>

Imagine profil
Abandonează
Autor Cel mai bun răspuns

I found the answer:

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

Update, or:

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



Imagine profil
Abandonează
Cel mai bun răspuns

You can write, also this,

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

FOO

</t>

Imagine profil
Abandonează
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 Răspunsuri Vizualizări Activitate
0
mar. 24
3356
3
oct. 16
6993
1
dec. 23
26987
1
mar. 15
7907
3
sept. 24
46986