XML Views
Examples target Odoo 18 and 19 unless marked. Platform covers Odoo 11 to 20.
Form Views
Basic Form View
xml
<form>
<sheet>
<group>
<field name="name"/>
<field name="date"/>
<field name="state"/>
</group>
</sheet>
</form>Form View with Notebook
xml
<form>
<sheet>
<group>
<field name="name"/>
<field name="date"/>
</group>
<notebook>
<page string="First Tab">
<group>
<field name="field1"/>
<field name="field2"/>
</group>
</page>
<page string="Second Tab">
<group>
<field name="field3"/>
<field name="field4"/>
</group>
</page>
</notebook>
</sheet>
</form>Form View with Statusbar
xml
<form>
<header>
<field name="state" widget="statusbar"/>
</header>
<sheet>
<group>
<field name="name"/>
<field name="date"/>
</group>
</sheet>
</form>List Views
Odoo 18 renamed the <tree> view root to <list>. Use <tree> on Odoo 17 and earlier.
Basic List View
xml
<list>
<field name="name"/>
<field name="date"/>
<field name="state"/>
</list>List View with Decorations
xml
<list decoration-info="state == 'draft'" decoration-success="state == 'done'">
<field name="name"/>
<field name="date"/>
<field name="state"/>
</list>List View with Buttons
xml
<list>
<field name="name"/>
<field name="date"/>
<field name="state"/>
<button name="action_confirm" string="Confirm" type="object"
invisible="state != 'draft'"/>
</list>Search Views
Basic Search View
xml
<search>
<field name="name"/>
<field name="date"/>
<filter string="Draft" name="draft" domain="[('state', '=', 'draft')]"/>
<group expand="0" string="Group By">
<filter string="State" name="state" context="{'group_by': 'state'}"/>
</group>
</search>Advanced Search View
xml
<search>
<field name="name"/>
<field name="partner_id"/>
<separator/>
<filter string="My Draft" name="my_draft"
domain="[('state', '=', 'draft'), ('user_id', '=', uid)]"/>
<filter string="Confirmed" name="confirmed"
domain="[('state', '=', 'confirmed')]"/>
<separator/>
<group expand="0" string="Group By">
<filter string="State" name="state" context="{'group_by': 'state'}"/>
<filter string="User" name="user" context="{'group_by': 'user_id'}"/>
</group>
</search>Calendar Views
Basic Calendar View
xml
<calendar string="Calendar" date_start="start_date" date_stop="end_date">
<field name="name"/>
<field name="partner_id"/>
</calendar>Calendar View with Color
xml
<calendar string="Calendar" date_start="start_date" date_stop="end_date"
color="partner_id" quick_add="false">
<field name="name"/>
<field name="partner_id"/>
</calendar>Kanban Views
Odoo 18 and later use t-name="card". Odoo 17 and earlier use t-name="kanban-box".
Basic Kanban View
xml
<kanban>
<field name="name"/>
<field name="state"/>
<templates>
<t t-name="card">
<field name="name" class="fw-bold"/>
<div><field name="state"/></div>
</t>
</templates>
</kanban>Kanban View with Image
xml
<kanban>
<field name="name"/>
<field name="image"/>
<templates>
<t t-name="card">
<img t-if="record.image.raw_value"
t-att-src="image_url('module', 'image', record.image.raw_value)"/>
<field name="name" class="fw-bold"/>
</t>
</templates>
</kanban>Common Attributes
Field Attributes
xml
<field name="field_name"
readonly="1"
required="1"
invisible="1"
nolabel="1"
placeholder="Enter value"
help="Help text"
widget="many2one"
options="{'no_create': True}"
class="oe_highlight"/>Group Attributes
xml
<group string="Group Title"
col="2"
colspan="2"
class="oe_subtotal_footer_separator">
<field name="field1"/>
<field name="field2"/>
</group>Button Attributes
xml
<button name="action_method"
string="Button Text"
type="object"
class="oe_highlight"
icon="fa-check"
invisible="state != 'draft'"/>From Odoo 17, invisible, readonly, required and the other dynamic attributes take a Python-style expression on the record fields. attrs and states are removed.
Inheritance
View Inheritance
xml
<record id="view_form_inherit" model="ir.ui.view">
<field name="name">model.form.inherit</field>
<field name="model">model.name</field>
<field name="inherit_id" ref="base_view_id"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="new_field"/>
</xpath>
</field>
</record>Multiple Inheritance
xml
<record id="view_form_inherit_multiple" model="ir.ui.view">
<field name="name">model.form.inherit.multiple</field>
<field name="model">model.name</field>
<field name="inherit_id" ref="base_view_id"/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="new_field"/>
</xpath>
</field>
</record>