تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
10120 أدوات العرض

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
مارس 24
3395
3
أكتوبر 16
7050
1
ديسمبر 23
27066
1
مارس 15
7981
3
سبتمبر 24
47056