PARTNERS
Chapter 19
View Inheritance
View Inheritance <record id="MODEL_view_TYPE" model="ir.ui.view">
<field name="name">model.view.type</field>
<field name="model">model</field>
<field name="arch" type="xml">
<VIEW_TYPE>
<VIEW_SPECIFICATIONS/>
● Define a New view </VIEW_TYPE>
as seen in chapter 6 </field>
</record>
<record id="inherit_MODEL_view_TYPE" model="ir.ui.view">
● Extend an existing one <field name="name">model.view.type.inherit</field>
<field name="model">model</field>
<field name="inherit_id" ref="module.inherited_view_id"/>
new field used : inherid_id
<field name="arch" type="xml">
<xpath expr="..." position="...">
<!-- do the appropriate modification… -->
</xpath>
</field>
</record>
CLICK HERE
Elements modification
expr: locating single element in parent view position: action to do
<xpath expr="//field[@name='name']" position="after">
<!-- do the appropriate modification… -->
</xpath>
elements depending on position value
CLICK HERE
Xpath - expr View to override
<form>
<sheet>
<div class="oe_button_box">
Locating a node on the view we are inheriting <BUTTONS/>
</div>
<group>
<group>
<xpath expr="//div[hasclass('oe_button_box')" position="..."> <field name="name"/>
<!-- finds the first div element using a class 'oe_button_box' … -->
</group>
</group>
</xpath>
<notebook>
<page string="Page1">
<group>
<CONTENT/>
<xpath expr="//field[@name='name']" position="..."> </group>
<!-- finds the first field tax anywhere with name: 'name' … --> </page>
</xpath> <page string="Page2">
<group>
<CONTENT/>
</group>
</page>
</notebook>
</sheet>
</form>
CLICK HERE
Xpath - position
Keys
<xpath expr="..." position="KEY">
before - inserts BODY before the matched element
<!-- BODY used based on the position value –->
<group>
<field name="new_field_1"/> after - inserts BODY after the matched element
</group>
inside
<group>
<field name="new_field_2"/> - appends BODY to the end of the matched element
</group>
</xpath>
replace - replaces the matched element with BODY
CLICK HERE
Xpath - position - attributes
<xpath expr="..." position="attributes">
<attribute name="invisible">0</attribute>
<attribute name="required">1</attribute> attributes - alters the attributes of the matched element
<attribute name="readonly">0</attribute> using the BODY’s elements
</xpath>
CLICK HERE
Exercise PARTNERS
Chapter 19
View inheritance Add new fields to the Users view.
Override the base.view_users_form to add the
property_ids field in a new notebook page.