Odoo Help

Welcome!

This community 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.

0

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

By
zbik
on 4/7/15, 10:08 AM 955 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>

1

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
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> 



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

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.

zbik
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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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