Skip to content

Backward compatibility

Introduction

In this guide we will explain how to make your views keep working in the old desktop client and the new webclient.

Working with view inheritance

The main idea is to create a new view that inherits from the old one and modify the base widgets to the new ones. For this we have to use the inherit_id and the version fields of the model ir.ui.view.

The views have version field that is used to define the version of the view, and when the client asks for a view, it will send the version it supports. Then the server will construct the view using inheritance and version supported by the client.

Example

<record id="crm_tree" model="ir.ui.view">
<field name="name">crm.case.tree</field>
<field name="model">crm.case</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="List of cases">
<field name="name"/>
<field name="email"/>
<field name="user_id" />
<field name="phone" />
<field name="date" />
<field name="state" />
</tree>
</field>
</record>

Then we can create a new view that inherits from the old one and modify the base widgets with the new ones.

<record id="crm_tree_web" model="ir.ui.view">
<field name="name">crm.case.tree</field>
<field name="model">crm.case</field>
<field name="inherit_id" ref="crm_tree"/>
<field name="type">tree</field>
<field name="version">2</field>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='user_id']" position="attributes">
<attribute name="widget">avatar</attribute>
</xpath>
<xpath expr="//field[@name='state']" position="attributes">
<attribute name="widget">tag</attribute>
<attribute name="widget_props">{'colors': {'draft': 'default', 'cancel': 'error', 'open': 'processing', 'done': 'success', 'pending': 'warning'}}</attribute>
</xpath>
</data>
</field>
</record>

Example without inheritance

In this case we use the attribute icon in the page tag that doesn’t exist in the old client.

<record id="crm_form" model="ir.ui.view">
<field name="name">crm.case.form</field>
<field name="model">crm.case</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Case">
<notebook>
<page string="General" icon="home">
<field name="name"/>
<field name="email"/>
<field name="user_id"/>
<field name="phone"/>
<field name="date"/>
</page>
</notebook>
</form>
</field>
</record>