Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views7 pages

6 - (En) View Inheritance

The document discusses view inheritance in a software framework, detailing how to define a new view and extend an existing one using XML. It explains the use of XPath expressions to locate and modify elements within inherited views, including changing positions and attributes. Additionally, it includes an exercise to add new fields to the Users view by overriding an existing form view.

Uploaded by

self fr33co
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views7 pages

6 - (En) View Inheritance

The document discusses view inheritance in a software framework, detailing how to define a new view and extend an existing one using XML. It explains the use of XPath expressions to locate and modify elements within inherited views, including changing positions and attributes. Additionally, it includes an exercise to add new fields to the Users view by overriding an existing form view.

Uploaded by

self fr33co
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

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.

You might also like