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

« back to all changes in this revision

Viewing changes to i18n/ru/source/developer/2_7_menu_action/7_2_actions.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: Actions
 
3
.. i18n: =======
 
4
..
 
5
 
 
6
Actions
 
7
=======
 
8
 
 
9
.. i18n: Introduction
 
10
.. i18n: ------------
 
11
..
 
12
 
 
13
Introduction
 
14
------------
 
15
 
 
16
.. i18n: The actions define the behavior of the system in response to the actions of the users ; login of a new user, double-click on an invoice, click on the action button, ...
 
17
..
 
18
 
 
19
The actions define the behavior of the system in response to the actions of the users ; login of a new user, double-click on an invoice, click on the action button, ...
 
20
 
 
21
.. i18n: There are different types of simple actions:
 
22
..
 
23
 
 
24
There are different types of simple actions:
 
25
 
 
26
.. i18n:     * Window: Opening of a new window
 
27
.. i18n:     * Report: The printing of a report
 
28
.. i18n:           o Custom Report: The personalized reports
 
29
.. i18n:           o RML Report: The XSL:RML reports
 
30
.. i18n:     * Wizard: The beginning of a Wizard
 
31
.. i18n:     * Execute: The execution of a method on the server side
 
32
.. i18n:     * Group: Gather some actions in one group
 
33
..
 
34
 
 
35
    * Window: Opening of a new window
 
36
    * Report: The printing of a report
 
37
          o Custom Report: The personalized reports
 
38
          o RML Report: The XSL:RML reports
 
39
    * Wizard: The beginning of a Wizard
 
40
    * Execute: The execution of a method on the server side
 
41
    * Group: Gather some actions in one group
 
42
 
 
43
.. i18n: The actions are used for the following events;
 
44
..
 
45
 
 
46
The actions are used for the following events;
 
47
 
 
48
.. i18n:     * User connection,
 
49
.. i18n:     * The user double-clicks on the menu,
 
50
.. i18n:     * The user clicks on the icon 'print' or 'action'.
 
51
..
 
52
 
 
53
    * User connection,
 
54
    * The user double-clicks on the menu,
 
55
    * The user clicks on the icon 'print' or 'action'.
 
56
 
 
57
.. i18n: Example of events
 
58
.. i18n: -----------------
 
59
..
 
60
 
 
61
Example of events
 
62
-----------------
 
63
 
 
64
.. i18n: In OpenERP, all the actions are described and not configured. Two examples:
 
65
..
 
66
 
 
67
In OpenERP, all the actions are described and not configured. Two examples:
 
68
 
 
69
.. i18n:     * Opening of a window when double-clicking in the menu
 
70
.. i18n:     * User connection
 
71
..
 
72
 
 
73
    * Opening of a window when double-clicking in the menu
 
74
    * User connection
 
75
 
 
76
.. i18n: Opening of the menu
 
77
.. i18n: +++++++++++++++++++
 
78
..
 
79
 
 
80
Opening of the menu
 
81
+++++++++++++++++++
 
82
 
 
83
.. i18n: When the user open the option of the menu "Operations > Partners > Partners Contact", the next steps are done to give the user information on the action to undertake.
 
84
..
 
85
 
 
86
When the user open the option of the menu "Operations > Partners > Partners Contact", the next steps are done to give the user information on the action to undertake.
 
87
 
 
88
.. i18n:    1. Search the action in the IR.
 
89
.. i18n:    2. Execution of the action
 
90
.. i18n:          1. If the action is the type Opening the Window; it indicates to the user that a new window must be opened for a selected object and it gives you the view (form or list) and the filed to use (only the pro-forma invoice).
 
91
.. i18n:          2. The user asks the object and receives information necessary to trace a form; the fields description and the XML view.
 
92
..
 
93
 
 
94
   1. Search the action in the IR.
 
95
   2. Execution of the action
 
96
         1. If the action is the type Opening the Window; it indicates to the user that a new window must be opened for a selected object and it gives you the view (form or list) and the filed to use (only the pro-forma invoice).
 
97
         2. The user asks the object and receives information necessary to trace a form; the fields description and the XML view.
 
98
 
 
99
.. i18n: User connection
 
100
.. i18n: +++++++++++++++
 
101
..
 
102
 
 
103
User connection
 
104
+++++++++++++++
 
105
 
 
106
.. i18n: When a new user is connected to the server, the client must search the action to use for the first screen of this user. Generally, this action is: open the menu in the 'Operations' section.
 
107
..
 
108
 
 
109
When a new user is connected to the server, the client must search the action to use for the first screen of this user. Generally, this action is: open the menu in the 'Operations' section.
 
110
 
 
111
.. i18n: The steps are:
 
112
..
 
113
 
 
114
The steps are:
 
115
 
 
116
.. i18n:    1. Reading of a user file to obtain ACTION_ID
 
117
.. i18n:    2. Reading of the action and execution of this one
 
118
..
 
119
 
 
120
   1. Reading of a user file to obtain ACTION_ID
 
121
   2. Reading of the action and execution of this one
 
122
 
 
123
.. i18n: The fields
 
124
.. i18n: ++++++++++
 
125
..
 
126
 
 
127
The fields
 
128
++++++++++
 
129
 
 
130
.. i18n: **Action Name**
 
131
.. i18n:        The action name
 
132
.. i18n: **Action Type**
 
133
.. i18n:        Always 'ir.actions.act_window'
 
134
.. i18n: **View Ref**
 
135
.. i18n:        The view used for showing the object
 
136
.. i18n: **Model**
 
137
.. i18n:        The model of the object to post
 
138
.. i18n: **Type of View**
 
139
.. i18n:        The type of view (Tree/Form)
 
140
.. i18n: **Domain Value**
 
141
.. i18n:        The domain that decreases the visible data with this view
 
142
..
 
143
 
 
144
**Action Name**
 
145
        The action name
 
146
**Action Type**
 
147
        Always 'ir.actions.act_window'
 
148
**View Ref**
 
149
        The view used for showing the object
 
150
**Model**
 
151
        The model of the object to post
 
152
**Type of View**
 
153
        The type of view (Tree/Form)
 
154
**Domain Value**
 
155
        The domain that decreases the visible data with this view
 
156
 
 
157
.. i18n: The view
 
158
.. i18n: --------
 
159
.. i18n: The view describes how the edition form or the data tree/list appear on screen. The views can be of 'Form' or 'Tree' type, according to whether they represent a form for the edition or a list/tree for global data viewing.
 
160
..
 
161
 
 
162
The view
 
163
--------
 
164
The view describes how the edition form or the data tree/list appear on screen. The views can be of 'Form' or 'Tree' type, according to whether they represent a form for the edition or a list/tree for global data viewing.
 
165
 
 
166
.. i18n: A form can be called by an action opening in 'Tree' mode. The form view is generally opened from the list mode (like if the user pushes on 'switch view').
 
167
..
 
168
 
 
169
A form can be called by an action opening in 'Tree' mode. The form view is generally opened from the list mode (like if the user pushes on 'switch view').
 
170
 
 
171
.. i18n: The domain
 
172
.. i18n: ----------
 
173
..
 
174
 
 
175
The domain
 
176
----------
 
177
 
 
178
.. i18n: This parameter allows you to regulate which resources are visible in a selected view.(restriction)
 
179
..
 
180
 
 
181
This parameter allows you to regulate which resources are visible in a selected view.(restriction)
 
182
 
 
183
.. i18n: For example, in the invoice case, you can define an action that opens a view that shows only invoices not paid.
 
184
..
 
185
 
 
186
For example, in the invoice case, you can define an action that opens a view that shows only invoices not paid.
 
187
 
 
188
.. i18n: The domains are written in python; list of tuples. The tuples have three elements;
 
189
..
 
190
 
 
191
The domains are written in python; list of tuples. The tuples have three elements;
 
192
 
 
193
.. i18n:     * the field on which the test must be done
 
194
.. i18n:     * the operator used for the test (<, >, =, like)
 
195
.. i18n:     * the tested value
 
196
..
 
197
 
 
198
    * the field on which the test must be done
 
199
    * the operator used for the test (<, >, =, like)
 
200
    * the tested value
 
201
 
 
202
.. i18n: For example, if you want to obtain only 'Draft' invoice, use the following domain; [('state','=','draft')]
 
203
..
 
204
 
 
205
For example, if you want to obtain only 'Draft' invoice, use the following domain; [('state','=','draft')]
 
206
 
 
207
.. i18n: In the case of a simple view, the domain define the resources which are the roots of the tree. The other resources, even if they are not from a part of the domain will be posted if the user develop the branches of the tree.
 
208
..
 
209
 
 
210
In the case of a simple view, the domain define the resources which are the roots of the tree. The other resources, even if they are not from a part of the domain will be posted if the user develop the branches of the tree.
 
211
 
 
212
.. i18n: Window Action
 
213
.. i18n: -------------
 
214
..
 
215
 
 
216
Window Action
 
217
-------------
 
218
 
 
219
.. i18n: Actions are explained in more detail in section "Administration Modules - Actions". Here's the template of an action XML record :
 
220
.. i18n: ::
 
221
.. i18n: 
 
222
.. i18n:        <record model="ir.actions.act_window" id="action_id_1">
 
223
.. i18n:            <field name="name">action.name</field>
 
224
.. i18n:            <field name="view_id" ref="view_id_1"/>
 
225
.. i18n:            <field name="domain">["list of 3-tuples (max 250 characters)"]</field>
 
226
.. i18n:            <field name="context">{"context dictionary (max 250 characters)"}</field>
 
227
.. i18n:            <field name="res_model">Open.object</field>
 
228
.. i18n:            <field name="view_type">form|tree</field>
 
229
.. i18n:            <field name="view_mode">form,tree|tree,form|form|tree</field>
 
230
.. i18n:            <field name="usage">menu</field>
 
231
.. i18n:            <field name="target">new</field>
 
232
.. i18n:        </record>
 
233
..
 
234
 
 
235
Actions are explained in more detail in section "Administration Modules - Actions". Here's the template of an action XML record :
 
236
::
 
237
 
 
238
        <record model="ir.actions.act_window" id="action_id_1">
 
239
            <field name="name">action.name</field>
 
240
            <field name="view_id" ref="view_id_1"/>
 
241
            <field name="domain">["list of 3-tuples (max 250 characters)"]</field>
 
242
            <field name="context">{"context dictionary (max 250 characters)"}</field>
 
243
            <field name="res_model">Open.object</field>
 
244
            <field name="view_type">form|tree</field>
 
245
            <field name="view_mode">form,tree|tree,form|form|tree</field>
 
246
            <field name="usage">menu</field>
 
247
            <field name="target">new</field>
 
248
        </record>
 
249
 
 
250
.. i18n: **Where**
 
251
..
 
252
 
 
253
**Where**
 
254
 
 
255
.. i18n:     * **id** is the identifier of the action in the table "ir.actions.act_window". It must be unique.
 
256
.. i18n:     * **name** is the name of the action (mandatory).
 
257
.. i18n:     * **view_id** is the name of the view to display when the action is activated. If this field is not defined, the view of a kind (list or form) associated to the object res_model with the highest priority field is used (if two views have the same priority, the first defined view of a kind is used).
 
258
.. i18n:     * **domain** is a list of constraints used to refine the results of a selection, and hence to get less records displayed in the view. Constraints of the list are linked together with an AND clause : a record of the table will be displayed in the view only if all the constraints are satisfied.
 
259
.. i18n:     * **context** is the context dictionary which will be visible in the view that will be opened when the action is activated. Context dictionaries are declared with the same syntax as Python dictionaries in the XML file. For more information about context dictionaries, see section " The context Dictionary".
 
260
.. i18n:     * **res_model** is the name of the object on which the action operates.
 
261
.. i18n:     * **view_type** is set to form when the action must open a new form view, and is set to tree when the action must open a new tree view.
 
262
.. i18n:     * **view_mode** is only considered if view_type is form, and ignored otherwise. The four possibilities are :
 
263
.. i18n:           - **form,tree** : the view is first displayed as a form, the list view can be displayed by clicking the "alternate view button" ;
 
264
.. i18n:           - **tree,form** : the view is first displayed as a list, the form view can be displayed by clicking the "alternate view button" ;
 
265
.. i18n:           - **form** : the view is displayed as a form and there is no way to switch to list view ;
 
266
.. i18n:           - **tree** : the view is displayed as a list and there is no way to switch to form view.
 
267
..
 
268
 
 
269
    * **id** is the identifier of the action in the table "ir.actions.act_window". It must be unique.
 
270
    * **name** is the name of the action (mandatory).
 
271
    * **view_id** is the name of the view to display when the action is activated. If this field is not defined, the view of a kind (list or form) associated to the object res_model with the highest priority field is used (if two views have the same priority, the first defined view of a kind is used).
 
272
    * **domain** is a list of constraints used to refine the results of a selection, and hence to get less records displayed in the view. Constraints of the list are linked together with an AND clause : a record of the table will be displayed in the view only if all the constraints are satisfied.
 
273
    * **context** is the context dictionary which will be visible in the view that will be opened when the action is activated. Context dictionaries are declared with the same syntax as Python dictionaries in the XML file. For more information about context dictionaries, see section " The context Dictionary".
 
274
    * **res_model** is the name of the object on which the action operates.
 
275
    * **view_type** is set to form when the action must open a new form view, and is set to tree when the action must open a new tree view.
 
276
    * **view_mode** is only considered if view_type is form, and ignored otherwise. The four possibilities are :
 
277
          - **form,tree** : the view is first displayed as a form, the list view can be displayed by clicking the "alternate view button" ;
 
278
          - **tree,form** : the view is first displayed as a list, the form view can be displayed by clicking the "alternate view button" ;
 
279
          - **form** : the view is displayed as a form and there is no way to switch to list view ;
 
280
          - **tree** : the view is displayed as a list and there is no way to switch to form view.
 
281
 
 
282
.. i18n: (version 5 introduced **graph** and **calendar** views)
 
283
..
 
284
 
 
285
(version 5 introduced **graph** and **calendar** views)
 
286
 
 
287
.. i18n:     * **usage** is used [+ ***TODO*** +]
 
288
.. i18n:     * **target** the view will open in new window like wizard.
 
289
..
 
290
 
 
291
    * **usage** is used [+ ***TODO*** +]
 
292
    * **target** the view will open in new window like wizard.
 
293
 
 
294
.. i18n: They indicate at the user that he has to open a new window in a new 'tab'.
 
295
..
 
296
 
 
297
They indicate at the user that he has to open a new window in a new 'tab'.
 
298
 
 
299
.. i18n: Administration > Custom > Low Level > Base > Action > Window Actions
 
300
..
 
301
 
 
302
Administration > Custom > Low Level > Base > Action > Window Actions
 
303
 
 
304
.. i18n: .. figure::  images/module_base_action_window.png
 
305
.. i18n:    :scale: 85
 
306
.. i18n:    :align: center
 
307
..
 
308
 
 
309
.. figure::  images/module_base_action_window.png
 
310
   :scale: 85
 
311
   :align: center
 
312
 
 
313
.. i18n: Examples of actions
 
314
.. i18n: +++++++++++++++++++
 
315
..
 
316
 
 
317
Examples of actions
 
318
+++++++++++++++++++
 
319
 
 
320
.. i18n: This action is declared in server/bin/addons/project/project_view.xml.
 
321
.. i18n: ::
 
322
.. i18n: 
 
323
.. i18n:     <record model="ir.actions.act_window" id="open_view_my_project">
 
324
.. i18n:         <field name="name">project.project</field>
 
325
.. i18n:         <field name="res_model">project.project</field>
 
326
.. i18n:         <field name="view_type">tree</field>
 
327
.. i18n:         <field name="domain">[('parent_id','=',False), ('manager', '=', uid)]</field>
 
328
.. i18n:         <field name="view_id" ref="view_my_project" />
 
329
.. i18n:     </record>
 
330
..
 
331
 
 
332
This action is declared in server/bin/addons/project/project_view.xml.
 
333
::
 
334
 
 
335
    <record model="ir.actions.act_window" id="open_view_my_project">
 
336
        <field name="name">project.project</field>
 
337
        <field name="res_model">project.project</field>
 
338
        <field name="view_type">tree</field>
 
339
        <field name="domain">[('parent_id','=',False), ('manager', '=', uid)]</field>
 
340
        <field name="view_id" ref="view_my_project" />
 
341
    </record>
 
342
 
 
343
.. i18n: This action is declared in server/bin/addons/stock/stock_view.xml.
 
344
.. i18n: ::
 
345
.. i18n: 
 
346
.. i18n:     <record model="ir.actions.act_window" id="action_picking_form">
 
347
.. i18n:         <field name="name">stock.picking</field>
 
348
.. i18n:         <field name="res_model">stock.picking</field>
 
349
.. i18n:         <field name="type">ir.actions.act_window</field>
 
350
.. i18n:         <field name="view_type">form</field>
 
351
.. i18n:         <field name="view_id" ref="view_picking_form"/>
 
352
.. i18n:         <field name="context">{'contact_display': 'partner'}</field>
 
353
.. i18n:     </record>
 
354
..
 
355
 
 
356
This action is declared in server/bin/addons/stock/stock_view.xml.
 
357
::
 
358
 
 
359
    <record model="ir.actions.act_window" id="action_picking_form">
 
360
        <field name="name">stock.picking</field>
 
361
        <field name="res_model">stock.picking</field>
 
362
        <field name="type">ir.actions.act_window</field>
 
363
        <field name="view_type">form</field>
 
364
        <field name="view_id" ref="view_picking_form"/>
 
365
        <field name="context">{'contact_display': 'partner'}</field>
 
366
    </record>
 
367
 
 
368
.. i18n: Url Action
 
369
.. i18n: -----------
 
370
..
 
371
 
 
372
Url Action
 
373
-----------
 
374
 
 
375
.. i18n: Wizard Action
 
376
.. i18n: -------------
 
377
..
 
378
 
 
379
Wizard Action
 
380
-------------
 
381
 
 
382
.. i18n: Here's an example of a .XML file that declares a wizard.
 
383
.. i18n: ::
 
384
.. i18n: 
 
385
.. i18n:        <?xml version="1.0"?>
 
386
.. i18n:        <openerp>
 
387
.. i18n:            <data>
 
388
.. i18n:                 <wizard string="Employee Info"
 
389
.. i18n:                         model="hr.employee"
 
390
.. i18n:                         name="employee.info.wizard"
 
391
.. i18n:                         id="wizard_employee_info"/>
 
392
.. i18n:            </data>
 
393
.. i18n:        </openerp>
 
394
..
 
395
 
 
396
Here's an example of a .XML file that declares a wizard.
 
397
::
 
398
 
 
399
        <?xml version="1.0"?>
 
400
        <openerp>
 
401
            <data>
 
402
                 <wizard string="Employee Info"
 
403
                         model="hr.employee"
 
404
                         name="employee.info.wizard"
 
405
                         id="wizard_employee_info"/>
 
406
            </data>
 
407
        </openerp>
 
408
 
 
409
.. i18n: A wizard is declared using a wizard tag. See "Add A New Wizard" for more information about wizard XML.
 
410
..
 
411
 
 
412
A wizard is declared using a wizard tag. See "Add A New Wizard" for more information about wizard XML.
 
413
 
 
414
.. i18n: also you can add wizard in menu using following xml entry
 
415
.. i18n: ::
 
416
.. i18n: 
 
417
.. i18n:     <?xml version="1.0"?>
 
418
.. i18n:     <openerp>
 
419
.. i18n:          <data>
 
420
.. i18n:          <wizard string="Employee Info"
 
421
.. i18n:                  model="hr.employee"
 
422
.. i18n:                  name="employee.info.wizard"
 
423
.. i18n:                  id="wizard_employee_info"/>
 
424
.. i18n:          <menuitem
 
425
.. i18n:                  name="Human Resource/Employee Info"
 
426
.. i18n:                  action="wizard_employee_info"
 
427
.. i18n:                  type="wizard"
 
428
.. i18n:                  id="menu_wizard_employee_info"/>
 
429
.. i18n:          </data>
 
430
.. i18n:     </openerp>
 
431
..
 
432
 
 
433
also you can add wizard in menu using following xml entry
 
434
::
 
435
 
 
436
    <?xml version="1.0"?>
 
437
    <openerp>
 
438
         <data>
 
439
         <wizard string="Employee Info"
 
440
                 model="hr.employee"
 
441
                 name="employee.info.wizard"
 
442
                 id="wizard_employee_info"/>
 
443
         <menuitem
 
444
                 name="Human Resource/Employee Info"
 
445
                 action="wizard_employee_info"
 
446
                 type="wizard"
 
447
                 id="menu_wizard_employee_info"/>
 
448
         </data>
 
449
    </openerp>
 
450
 
 
451
.. i18n: Report Action
 
452
.. i18n: -------------
 
453
..
 
454
 
 
455
Report Action
 
456
-------------
 
457
 
 
458
.. i18n: Report declaration
 
459
.. i18n: ++++++++++++++++++
 
460
..
 
461
 
 
462
Report declaration
 
463
++++++++++++++++++
 
464
 
 
465
.. i18n: Reports in OpenERP are explained in chapter "Reports Reporting". Here's an example of a XML file that declares a RML report :
 
466
.. i18n: ::
 
467
.. i18n: 
 
468
.. i18n:     <?xml version="1.0"?>
 
469
.. i18n:     <openerp>
 
470
.. i18n:         <data>
 
471
.. i18n:         <report id="sale_category_print"
 
472
.. i18n:                 string="Sales Orders By Categories"
 
473
.. i18n:                 model="sale.order"
 
474
.. i18n:                 name="sale_category.print"
 
475
.. i18n:                 rml="sale_category/report/sale_category_report.rml"
 
476
.. i18n:                 menu="True"
 
477
.. i18n:                 auto="False"/>
 
478
.. i18n:          </data>
 
479
.. i18n:     </openerp>
 
480
..
 
481
 
 
482
Reports in OpenERP are explained in chapter "Reports Reporting". Here's an example of a XML file that declares a RML report :
 
483
::
 
484
 
 
485
    <?xml version="1.0"?>
 
486
    <openerp>
 
487
        <data>
 
488
        <report id="sale_category_print"
 
489
                string="Sales Orders By Categories"
 
490
                model="sale.order"
 
491
                name="sale_category.print"
 
492
                rml="sale_category/report/sale_category_report.rml"
 
493
                menu="True"
 
494
                auto="False"/>
 
495
         </data>
 
496
    </openerp>
 
497
 
 
498
.. i18n: A report is declared using a **report tag** inside a "data" block. The different arguments of a report tag are :
 
499
..
 
500
 
 
501
A report is declared using a **report tag** inside a "data" block. The different arguments of a report tag are :
 
502
 
 
503
.. i18n:     * **id** : an identifier which must be unique.
 
504
.. i18n:     * **string** : the text of the menu that calls the report (if any, see below).
 
505
.. i18n:     * **model** : the OpenERP object on which the report will be rendered.
 
506
.. i18n:     * **rml** : the .RML report model. Important Note : Path is relative to addons/ directory.
 
507
.. i18n:     * **menu** : whether the report will be able to be called directly via the client or not. Setting menu to False is useful in case of reports called by wizards.
 
508
.. i18n:     * **auto** : determines if the .RML file must be parsed using the default parser or not. Using a custom parser allows you to define additional functions to your report.
 
509
..
 
510
 
 
511
    * **id** : an identifier which must be unique.
 
512
    * **string** : the text of the menu that calls the report (if any, see below).
 
513
    * **model** : the OpenERP object on which the report will be rendered.
 
514
    * **rml** : the .RML report model. Important Note : Path is relative to addons/ directory.
 
515
    * **menu** : whether the report will be able to be called directly via the client or not. Setting menu to False is useful in case of reports called by wizards.
 
516
    * **auto** : determines if the .RML file must be parsed using the default parser or not. Using a custom parser allows you to define additional functions to your report.