Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
10311 Widoki

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>

Awatar
Odrzuć
Autor Najlepsza odpowiedź

I found the answer:

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

Update, or:

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



Awatar
Odrzuć
Najlepsza odpowiedź

You can write, also this,

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

FOO

</t>

Awatar
Odrzuć
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)".

Powiązane posty Odpowiedzi Widoki Czynność
0
mar 24
3602
3
paź 16
7202
1
gru 23
27289
1
mar 15
8163
2
wrz 25
199