Skip to Content
Menu
This question has been flagged
1 Reply
19267 Views

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

<if........>
<field name="name" />
<if......./>
Avatar
Discard
Best Answer

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)

Example:

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

Avatar
Discard