~openerp-community/openobject-doc/ksa-openobject-doc-6.0

« back to all changes in this revision

Viewing changes to i18n/ru/source/developer/2_6_views_events/views/view_inheritence.rst

  • Committer: Don Kirkby
  • Date: 2011-02-21 20:46:11 UTC
  • mfrom: (433.1.53 openobject-doc)
  • Revision ID: donkirkby+launpd@gmail.com-20110221204611-1ykt6dmg4k3gh5dh
[MERGE] revisions 477 to 486 from the 5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
.. i18n: Inheritance in Views 
 
3
.. i18n: ==================== 
 
4
..
 
5
 
 
6
Inheritance in Views 
 
7
==================== 
 
8
 
 
9
.. 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
..
 
11
 
 
12
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.
 
13
 
 
14
.. i18n: :Example:
 
15
..
 
16
 
 
17
:Example:
 
18
 
 
19
.. i18n: .. code-block:: xml
 
20
.. i18n: 
 
21
.. i18n:        <record model="ir.ui.view" id="view_partner_form">
 
22
.. i18n:            <field name="name">res.partner.form.inherit</field>
 
23
.. i18n:            <field name="model">res.partner</field>
 
24
.. i18n:            <field name="inherit_id" ref="base.view_partner_form"/>
 
25
.. i18n:            <field name="arch" type="xml">
 
26
.. i18n:                <notebook position="inside">
 
27
.. i18n:                    <page string="Relations">
 
28
.. i18n:                        <field name="relation_ids" colspan="4" nolabel="1"/>
 
29
.. i18n:                    </page>
 
30
.. i18n:                </notebook>
 
31
.. i18n:            </field>
 
32
.. i18n:        </record>
 
33
..
 
34
 
 
35
.. code-block:: xml
 
36
 
 
37
        <record model="ir.ui.view" id="view_partner_form">
 
38
            <field name="name">res.partner.form.inherit</field>
 
39
            <field name="model">res.partner</field>
 
40
            <field name="inherit_id" ref="base.view_partner_form"/>
 
41
            <field name="arch" type="xml">
 
42
                <notebook position="inside">
 
43
                    <page string="Relations">
 
44
                        <field name="relation_ids" colspan="4" nolabel="1"/>
 
45
                    </page>
 
46
                </notebook>
 
47
            </field>
 
48
        </record>
 
49
 
 
50
.. i18n: This will add a page to the notebook of the ``res.partner.form`` view in the 
 
51
.. i18n: base module.
 
52
..
 
53
 
 
54
This will add a page to the notebook of the ``res.partner.form`` view in the 
 
55
base module.
 
56
 
 
57
.. i18n: The inheritance engine will parse the existing view and search for the the root nodes of
 
58
..
 
59
 
 
60
The inheritance engine will parse the existing view and search for the the root nodes of
 
61
 
 
62
.. i18n: .. code-block:: xml
 
63
.. i18n: 
 
64
.. i18n:        <field name="arch" type="xml">
 
65
..
 
66
 
 
67
.. code-block:: xml
 
68
 
 
69
        <field name="arch" type="xml">
 
70
 
 
71
.. i18n: It will append or edit the content of this tag. If this tag has some attributes, 
 
72
.. i18n: it will look in the parent view for a node with matching attributes (except 
 
73
.. i18n: position).
 
74
..
 
75
 
 
76
It will append or edit the content of this tag. If this tag has some attributes, 
 
77
it will look in the parent view for a node with matching attributes (except 
 
78
position).
 
79
 
 
80
.. i18n: You can use these values in the position attribute:
 
81
..
 
82
 
 
83
You can use these values in the position attribute:
 
84
 
 
85
.. i18n:     * inside (default): your values will be appended inside the tag
 
86
.. i18n:     * after: add the content after the tag
 
87
.. i18n:     * before: add the content before the tag
 
88
.. i18n:     * replace: replace the content of the tag. 
 
89
..
 
90
 
 
91
    * inside (default): your values will be appended inside the tag
 
92
    * after: add the content after the tag
 
93
    * before: add the content before the tag
 
94
    * replace: replace the content of the tag. 
 
95
 
 
96
.. i18n: Replacing Content
 
97
.. i18n: ~~~~~~~~~~~~~~~~~
 
98
..
 
99
 
 
100
Replacing Content
 
101
~~~~~~~~~~~~~~~~~
 
102
 
 
103
.. i18n: .. code-block:: xml
 
104
.. i18n: 
 
105
.. i18n:        <record model="ir.ui.view" id="view_partner_form1">
 
106
.. i18n:            <field name="name">res.partner.form.inherit1</field>
 
107
.. i18n:            <field name="model">res.partner</field>
 
108
.. i18n:            <field name="inherit_id" ref="base.view_partner_form"/>
 
109
.. i18n:            <field name="arch" type="xml">
 
110
.. i18n:                <page string="Extra Info" position="replace">
 
111
.. i18n:                    <field name="relation_ids" colspan="4" nolabel="1"/>
 
112
.. i18n:                </page>
 
113
.. i18n:            </field>
 
114
.. i18n:        </record>
 
115
..
 
116
 
 
117
.. code-block:: xml
 
118
 
 
119
        <record model="ir.ui.view" id="view_partner_form1">
 
120
            <field name="name">res.partner.form.inherit1</field>
 
121
            <field name="model">res.partner</field>
 
122
            <field name="inherit_id" ref="base.view_partner_form"/>
 
123
            <field name="arch" type="xml">
 
124
                <page string="Extra Info" position="replace">
 
125
                    <field name="relation_ids" colspan="4" nolabel="1"/>
 
126
                </page>
 
127
            </field>
 
128
        </record>
 
129
 
 
130
.. i18n: Will replace the content of the Extra Info tab of the notebook with the ``relation_ids`` field.
 
131
..
 
132
 
 
133
Will replace the content of the Extra Info tab of the notebook with the ``relation_ids`` field.
 
134
 
 
135
.. i18n: The parent and the inherited views are correctly updated with ``--update=all`` argument like any other views.
 
136
..
 
137
 
 
138
The parent and the inherited views are correctly updated with ``--update=all`` argument like any other views.
 
139
 
 
140
.. i18n: Deleting Content
 
141
.. i18n: ~~~~~~~~~~~~~~~~
 
142
..
 
143
 
 
144
Deleting Content
 
145
~~~~~~~~~~~~~~~~
 
146
 
 
147
.. i18n: To delete a field from a form, an empty element with ``position="replace"`` attribute is used. Example:
 
148
..
 
149
 
 
150
To delete a field from a form, an empty element with ``position="replace"`` attribute is used. Example:
 
151
 
 
152
.. i18n: .. code-block:: xml
 
153
.. i18n: 
 
154
.. i18n:        <record model="ir.ui.view" id="view_partner_form2">
 
155
.. i18n:            <field name="name">res.partner.form.inherit2</field>
 
156
.. i18n:            <field name="model">res.partner</field>
 
157
.. i18n:            <field name="inherit_id" ref="base.view_partner_form"/>
 
158
.. i18n:            <field name="arch" type="xml">
 
159
.. i18n:                <field name="lang" position="replace"/>
 
160
.. i18n:            </field>
 
161
.. i18n:        </record>
 
162
..
 
163
 
 
164
.. code-block:: xml
 
165
 
 
166
        <record model="ir.ui.view" id="view_partner_form2">
 
167
            <field name="name">res.partner.form.inherit2</field>
 
168
            <field name="model">res.partner</field>
 
169
            <field name="inherit_id" ref="base.view_partner_form"/>
 
170
            <field name="arch" type="xml">
 
171
                <field name="lang" position="replace"/>
 
172
            </field>
 
173
        </record>
 
174
 
 
175
.. i18n: Inserting Content
 
176
.. i18n: ~~~~~~~~~~~~~~~~~
 
177
..
 
178
 
 
179
Inserting Content
 
180
~~~~~~~~~~~~~~~~~
 
181
 
 
182
.. i18n: To add a field into a form before the specified tag use ``position="before"`` attribute. 
 
183
..
 
184
 
 
185
To add a field into a form before the specified tag use ``position="before"`` attribute. 
 
186
 
 
187
.. i18n: .. code-block:: xml
 
188
.. i18n: 
 
189
.. i18n:        <record model="ir.ui.view" id="view_partner_form3">
 
190
.. i18n:            <field name="name">res.partner.form.inherit3</field>
 
191
.. i18n:            <field name="model">res.partner</field>
 
192
.. i18n:            <field name="inherit_id" ref="base.view_partner_form"/>
 
193
.. i18n:            <field name="arch" type="xml">
 
194
.. i18n:                <field name="lang" position="before">
 
195
.. i18n:                    <field name="relation_ids"/>
 
196
.. i18n:                </field>
 
197
.. i18n:            </field>
 
198
.. i18n:        </record>
 
199
.. i18n:        
 
200
.. i18n: Will add ``relation_ids`` field before the ``lang`` field.     
 
201
..
 
202
 
 
203
.. code-block:: xml
 
204
 
 
205
        <record model="ir.ui.view" id="view_partner_form3">
 
206
            <field name="name">res.partner.form.inherit3</field>
 
207
            <field name="model">res.partner</field>
 
208
            <field name="inherit_id" ref="base.view_partner_form"/>
 
209
            <field name="arch" type="xml">
 
210
                <field name="lang" position="before">
 
211
                    <field name="relation_ids"/>
 
212
                </field>
 
213
            </field>
 
214
        </record>
 
215
        
 
216
Will add ``relation_ids`` field before the ``lang`` field.      
 
217
 
 
218
.. i18n: To add a field into a form after the specified tag use ``position="after"`` attribute. 
 
219
..
 
220
 
 
221
To add a field into a form after the specified tag use ``position="after"`` attribute. 
 
222
 
 
223
.. i18n: .. code-block:: xml
 
224
.. i18n: 
 
225
.. i18n:        <record model="ir.ui.view" id="view_partner_form4">
 
226
.. i18n:            <field name="name">res.partner.form.inherit4</field>
 
227
.. i18n:            <field name="model">res.partner</field>
 
228
.. i18n:            <field name="inherit_id" ref="base.view_partner_form"/>
 
229
.. i18n:            <field name="arch" type="xml">
 
230
.. i18n:                <field name="lang" position="after">
 
231
.. i18n:                    <field name="relation_ids"/>
 
232
.. i18n:                </field>
 
233
.. i18n:            </field>
 
234
.. i18n:        </record>
 
235
.. i18n:        
 
236
.. i18n: Will add ``relation_ids`` field after the ``lang`` field.
 
237
..
 
238
 
 
239
.. code-block:: xml
 
240
 
 
241
        <record model="ir.ui.view" id="view_partner_form4">
 
242
            <field name="name">res.partner.form.inherit4</field>
 
243
            <field name="model">res.partner</field>
 
244
            <field name="inherit_id" ref="base.view_partner_form"/>
 
245
            <field name="arch" type="xml">
 
246
                <field name="lang" position="after">
 
247
                    <field name="relation_ids"/>
 
248
                </field>
 
249
            </field>
 
250
        </record>
 
251
        
 
252
Will add ``relation_ids`` field after the ``lang`` field.
 
253
 
 
254
.. i18n: Multiple Changes
 
255
.. i18n: ~~~~~~~~~~~~~~~~
 
256
..
 
257
 
 
258
Multiple Changes
 
259
~~~~~~~~~~~~~~~~
 
260
 
 
261
.. i18n: To make changes in more than one location, wrap the fields in a data element.
 
262
..
 
263
 
 
264
To make changes in more than one location, wrap the fields in a data element.
 
265
 
 
266
.. i18n: .. code-block:: xml
 
267
.. i18n: 
 
268
.. i18n:     <record model="ir.ui.view" id="view_partner_form5">
 
269
.. i18n:         <field name="name">res.partner.form.inherit5</field>
 
270
.. i18n:         <field name="model">res.partner</field>
 
271
.. i18n:         <field name="inherit_id" ref="base.view_partner_form"/>
 
272
.. i18n:         <field name="arch" type="xml">
 
273
.. i18n:             <data>
 
274
.. i18n:                 <field name="lang" position="replace"/>
 
275
.. i18n:                 <field name="website" position="after">
 
276
.. i18n:                     <field name="lang"/>
 
277
.. i18n:                 </field>
 
278
.. i18n:             </data>
 
279
.. i18n:         </field>
 
280
.. i18n:     </record>
 
281
..
 
282
 
 
283
.. code-block:: xml
 
284
 
 
285
    <record model="ir.ui.view" id="view_partner_form5">
 
286
        <field name="name">res.partner.form.inherit5</field>
 
287
        <field name="model">res.partner</field>
 
288
        <field name="inherit_id" ref="base.view_partner_form"/>
 
289
        <field name="arch" type="xml">
 
290
            <data>
 
291
                <field name="lang" position="replace"/>
 
292
                <field name="website" position="after">
 
293
                    <field name="lang"/>
 
294
                </field>
 
295
            </data>
 
296
        </field>
 
297
    </record>
 
298
 
 
299
.. i18n: Will delete the ``lang`` field from its usual location, and display it after
 
300
.. i18n: the ``website`` field.
 
301
..
 
302
 
 
303
Will delete the ``lang`` field from its usual location, and display it after
 
304
the ``website`` field.
 
305
 
 
306
.. i18n: .. _xpath-element-inheritance:
 
307
.. i18n: 
 
308
.. i18n: XPath Element
 
309
.. i18n: ~~~~~~~~~~~~~
 
310
..
 
311
 
 
312
.. _xpath-element-inheritance:
 
313
 
 
314
XPath Element
 
315
~~~~~~~~~~~~~
 
316
 
 
317
.. i18n: Sometimes a view is too complicated to let you simply identify a target field
 
318
.. i18n: by name. For example, the field might appear in two places. When that happens,
 
319
.. i18n: you can use an ``xpath`` element to describe where your changes should be 
 
320
.. i18n: placed. 
 
321
..
 
322
 
 
323
Sometimes a view is too complicated to let you simply identify a target field
 
324
by name. For example, the field might appear in two places. When that happens,
 
325
you can use an ``xpath`` element to describe where your changes should be 
 
326
placed. 
 
327
 
 
328
.. i18n: .. code-block:: xml
 
329
.. i18n: 
 
330
.. i18n:     <record model="ir.ui.view" id="view_partner_form6">
 
331
.. i18n:         <field name="name">res.partner.form.inherit6</field>
 
332
.. i18n:         <field name="model">res.partner</field>
 
333
.. i18n:         <field name="inherit_id" ref="base.view_partner_form"/>
 
334
.. i18n:         <field name="arch" type="xml">
 
335
.. i18n:             <data>
 
336
.. i18n:                 <xpath 
 
337
.. i18n:                     expr="//field[@name='address']/form/field[@name='email']"
 
338
.. i18n:                     position="after">
 
339
.. i18n:                     <field name="age"/>
 
340
.. i18n:                 </xpath>
 
341
.. i18n:                 <xpath 
 
342
.. i18n:                     expr="//field[@name='address']/tree/field[@name='email']"
 
343
.. i18n:                     position="after">
 
344
.. i18n:                     <field name="age"/>
 
345
.. i18n:                 </xpath>
 
346
.. i18n:             </data>
 
347
.. i18n:         </field>
 
348
.. i18n:     </record>
 
349
.. i18n:     
 
350
.. i18n: Will add the ``age`` field after the ``email`` field in both the form and tree 
 
351
.. i18n: view of the address list.       
 
352
..
 
353
 
 
354
.. code-block:: xml
 
355
 
 
356
    <record model="ir.ui.view" id="view_partner_form6">
 
357
        <field name="name">res.partner.form.inherit6</field>
 
358
        <field name="model">res.partner</field>
 
359
        <field name="inherit_id" ref="base.view_partner_form"/>
 
360
        <field name="arch" type="xml">
 
361
            <data>
 
362
                <xpath 
 
363
                    expr="//field[@name='address']/form/field[@name='email']"
 
364
                    position="after">
 
365
                    <field name="age"/>
 
366
                </xpath>
 
367
                <xpath 
 
368
                    expr="//field[@name='address']/tree/field[@name='email']"
 
369
                    position="after">
 
370
                    <field name="age"/>
 
371
                </xpath>
 
372
            </data>
 
373
        </field>
 
374
    </record>
 
375
    
 
376
Will add the ``age`` field after the ``email`` field in both the form and tree 
 
377
view of the address list.