Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
10027 Представления

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
3356
3
окт. 16
6993
1
дек. 23
26987
1
мар. 15
7907
3
сент. 24
46986