コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
10012 ビュー

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)".

関連投稿 返信 ビュー 活動
0
3月 24
3347
3
10月 16
6986
1
12月 23
26978
1
3月 15
7906
3
9月 24
46975