Odoo Help


Qweb - test the existence of fields in the model definition [SOLVED]?

on 4/7/15, 10:08 AM 1,059 views

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>



| 6 4 7
Lodz, Poland

On 4/7/15, 10:56 AM

I found the answer:

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

Update, or:

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

Rucha Dave (rda)
On 4/8/15, 2:10 AM

You can write, also this,

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



This is not a good solution, if filed xxx not exists in model cause the error: ... object has no attribute 'xxx'" while evaluating.

on 4/8/15, 6:17 AM

You are right, I misunderstood the question.. I forgot to notice "field exists (is defined in model)".

Rucha Dave (rda)
on 4/8/15, 6:26 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/7/15, 10:08 AM
Seen: 1059 times
Last updated: 6/30/15, 1:19 PM