Odoo Help


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.


Xml view file and if statement

George Tsagkogeorgas
on 11/9/13, 6:43 AM 3,241 views

Can I use "if" in a xml file (tree view)? How can I do this? e.g:

<field name="name" />

Daniel Reis

--Daniel Reis--
| 6 7 9
Lisbon, Portugal
--Daniel Reis--

Author of the "Odoo Development Essentials" book.

Applications Manager at Securitas Portugal

Github: https://github.com/dreispt

Twitter; @reis_pt

Daniel Reis
On 11/10/13, 1:36 PM

You can use the attrs attribute on form fields, to make them contitionally visible or required.

From the documentation:

attrs: Permits to define attributes of a field depends on other fields of the same window. (It can be use on page, group, button and notebook tag also)


<field name="volume" attrs="{'readonly':[('type','=','service')]}"/>

Views also use the QWeb template engine, used in many Kanban views, and it includes a t-if=condition element, but this is not very well documented.

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

0 follower(s)


Asked: 11/9/13, 6:43 AM
Seen: 3241 times
Last updated: 3/16/15, 8:10 AM