Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
10147 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
3448
3
říj 16
7087
1
pro 23
27125
1
bře 15
8032
3
zář 24
47149