2
.. i18n: Inheritance in Views
3
.. i18n: --------------------
8
.. i18n: When you create and inherit objects in some custom or specific modules, it is better to inherit (than to replace) from an existing view to add/modify/delete some fields and preserve the others.
10
When you create and inherit objects in some custom or specific modules, it is better to inherit (than to replace) from an existing view to add/modify/delete some fields and preserve the others.
16
.. i18n: .. code-block:: xml
18
.. i18n: <record model="ir.ui.view" id="view_partner_form">
19
.. i18n: <field name="name">res.partner.form.inherit</field>
20
.. i18n: <field name="model">res.partner</field>
21
.. i18n: <field name="inherit_id" ref="base.view_partner_form"/>
22
.. i18n: <field name="arch" type="xml">
23
.. i18n: <notebook position="inside">
24
.. i18n: <page string="Relations">
25
.. i18n: <field name="relation_ids" colspan="4" nolabel="1"/>
33
<record model="ir.ui.view" id="view_partner_form">
34
<field name="name">res.partner.form.inherit</field>
35
<field name="model">res.partner</field>
36
<field name="inherit_id" ref="base.view_partner_form"/>
37
<field name="arch" type="xml">
38
<notebook position="inside">
39
<page string="Relations">
40
<field name="relation_ids" colspan="4" nolabel="1"/>
46
.. i18n: The inheritance engine will parse the existing view and search for the the root nodes of
48
The inheritance engine will parse the existing view and search for the the root nodes of
50
.. i18n: .. code-block:: xml
52
.. i18n: <field name="arch" type="xml">
56
<field name="arch" type="xml">
58
.. i18n: It will append or edit the content of this tag. If this tag has some attributes, it will look for the matching node, including the same attributes (unless position).
60
It will append or edit the content of this tag. If this tag has some attributes, it will look for the matching node, including the same attributes (unless position).
62
.. i18n: This will add a page to the notebook of the res.partner.form view in the base module.
64
This will add a page to the notebook of the res.partner.form view in the base module.
66
.. i18n: You can use these values in the position attribute:
68
You can use these values in the position attribute:
70
.. i18n: * inside (default): your values will be appended inside this tag
71
.. i18n: * after: add the content after this tag
72
.. i18n: * before: add the content before this tag
73
.. i18n: * replace: replace the content of the tag.
75
* inside (default): your values will be appended inside this tag
76
* after: add the content after this tag
77
* before: add the content before this tag
78
* replace: replace the content of the tag.
80
.. i18n: :Second Example:
84
.. i18n: .. code-block:: xml
86
.. i18n: <record model="ir.ui.view" id="view_partner_form">
87
.. i18n: <field name="name">res.partner.form.inherit</field>
88
.. i18n: <field name="model">res.partner</field>
89
.. i18n: <field name="inherit_id" ref="base.view_partner_form"/>
90
.. i18n: <field name="arch" type="xml">
91
.. i18n: <page string="Extra Info" position="replace">
92
.. i18n: <field name="relation_ids" colspan="4" nolabel="1"/>
99
<record model="ir.ui.view" id="view_partner_form">
100
<field name="name">res.partner.form.inherit</field>
101
<field name="model">res.partner</field>
102
<field name="inherit_id" ref="base.view_partner_form"/>
103
<field name="arch" type="xml">
104
<page string="Extra Info" position="replace">
105
<field name="relation_ids" colspan="4" nolabel="1"/>
110
.. i18n: Will replace the content of the Extra Info tab of the notebook by one 'relation_ids' field.
112
Will replace the content of the Extra Info tab of the notebook by one 'relation_ids' field.
114
.. i18n: The parent and the inherited views are correctly updated with --update=all argument like any other views.
116
The parent and the inherited views are correctly updated with --update=all argument like any other views.
118
.. i18n: To delete a field from a form, an empty element with position="replace" atribute is used. Example:
120
To delete a field from a form, an empty element with position="replace" atribute is used. Example:
122
.. i18n: .. code-block:: xml
124
.. i18n: <record model="ir.ui.view" id="view_partner_form3">
125
.. i18n: <field name="name">res.partner.form.inherit</field>
126
.. i18n: <field name="model">res.partner</field>
127
.. i18n: <field name="inherit_id" ref="base.view_partner_form"/>
128
.. i18n: <field name="arch" type="xml">
129
.. i18n: <field name="lang" position="replace"/>
135
<record model="ir.ui.view" id="view_partner_form3">
136
<field name="name">res.partner.form.inherit</field>
137
<field name="model">res.partner</field>
138
<field name="inherit_id" ref="base.view_partner_form"/>
139
<field name="arch" type="xml">
140
<field name="lang" position="replace"/>
144
.. i18n: Take into account that only one position="replace" attribute can be used per inherited view so multiple inherited views must be created to make multiple replacements.
146
Take into account that only one position="replace" attribute can be used per inherited view so multiple inherited views must be created to make multiple replacements.