Skip to Content
Menu
This question has been flagged
2 Replies
10117 Rodiniai

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>

Portretas
Atmesti
Autorius Best Answer

I found the answer:

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

Update, or:

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



Portretas
Atmesti
Best Answer

You can write, also this,

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

FOO

</t>

Portretas
Atmesti
Autorius

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 Replies Rodiniai Veikla
0
kov. 24
3395
3
spal. 16
7049
1
gruod. 23
27063
1
kov. 15
7978
3
rugs. 24
47048