Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
9970 Zobrazení

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
Zrušit
Autor Nejlepší odpověď

I found the answer:

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

Update, or:

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



Avatar
Zrušit
Nejlepší odpověď

You can write, also this,

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

FOO

</t>

Avatar
Zrušit
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 Odpovědi Zobrazení Aktivita
0
bře 24
3318
3
říj 16
6961
1
pro 23
26954
1
bře 15
7876
3
zář 24
46955