Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
10020 Переглядів

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>

Аватар
Відмінити
Автор Найкраща відповідь

I found the answer:

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

Update, or:

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



Аватар
Відмінити
Найкраща відповідь

You can write, also this,

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

FOO

</t>

Аватар
Відмінити
Автор

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 Відповіді Переглядів Дія
0
бер. 24
3354
3
жовт. 16
6991
1
груд. 23
26984
1
бер. 15
7907
3
вер. 24
46983