~openerp-community/openobject-doc/6.1

« back to all changes in this revision

Viewing changes to i18n/vi/source/developer/2_7_menu_action/7_2_actions.rst

  • Committer: TruongSinh Tran
  • Date: 2009-07-19 19:02:35 UTC
  • Revision ID: truongsinh@vipescoserver-20090719190235-fu3bxcrbpvwuk5h7
[FIX] build_i18n.py .. raw:: html

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
There are different types of simple actions:
21
21
 
22
 
    .. i18n: * Window: Opening of a new window
23
 
    .. i18n: * Report: The printing of a report
24
 
          .. i18n: o Custom Report: The personalized reports
25
 
          .. i18n: o RML Report: The XSL:RML reports
26
 
    .. i18n: * Wizard: The beginning of a Wizard
27
 
    .. i18n: * Execute: The execution of a method on the server side
28
 
    .. i18n: * Group: Gather some actions in one group
 
22
.. i18n:     * Window: Opening of a new window
 
23
.. i18n:     * Report: The printing of a report
 
24
.. i18n:           o Custom Report: The personalized reports
 
25
.. i18n:           o RML Report: The XSL:RML reports
 
26
.. i18n:     * Wizard: The beginning of a Wizard
 
27
.. i18n:     * Execute: The execution of a method on the server side
 
28
.. i18n:     * Group: Gather some actions in one group
29
29
 
30
30
    * Window: Opening of a new window
31
31
    * Report: The printing of a report
39
39
 
40
40
The actions are used for the following events;
41
41
 
42
 
    .. i18n: * User connection,
43
 
    .. i18n: * The user double-clicks on the menu,
44
 
    .. i18n: * The user clicks on the icon 'print' or 'action'.
 
42
.. i18n:     * User connection,
 
43
.. i18n:     * The user double-clicks on the menu,
 
44
.. i18n:     * The user clicks on the icon 'print' or 'action'.
45
45
 
46
46
    * User connection,
47
47
    * The user double-clicks on the menu,
57
57
 
58
58
In Open ERP, all the actions are described and not configured. Two examples:
59
59
 
60
 
    .. i18n: * Opening of a window when double-clicking in the menu
61
 
    .. i18n: * User connection
 
60
.. i18n:     * Opening of a window when double-clicking in the menu
 
61
.. i18n:     * User connection
62
62
 
63
63
    * Opening of a window when double-clicking in the menu
64
64
    * User connection
73
73
 
74
74
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.
75
75
 
76
 
   .. i18n: 1. Search the action in the IR.
77
 
   .. i18n: 2. Execution of the action
78
 
         .. 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).
79
 
         .. i18n: 2. The user asks the object and receives information necessary to trace a form; the fields description and the XML view.
 
76
.. i18n:    1. Search the action in the IR.
 
77
.. i18n:    2. Execution of the action
 
78
.. 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).
 
79
.. i18n:          2. The user asks the object and receives information necessary to trace a form; the fields description and the XML view.
80
80
 
81
81
   1. Search the action in the IR.
82
82
   2. Execution of the action
97
97
 
98
98
The steps are:
99
99
 
100
 
   .. i18n: 1. Reading of a user file to obtain ACTION_ID
101
 
   .. i18n: 2. Reading of the action and execution of this one
 
100
.. i18n:    1. Reading of a user file to obtain ACTION_ID
 
101
.. i18n:    2. Reading of the action and execution of this one
102
102
 
103
103
   1. Reading of a user file to obtain ACTION_ID
104
104
   2. Reading of the action and execution of this one
110
110
++++++++++
111
111
 
112
112
.. i18n: **Action Name**
113
 
        .. i18n: The action name
 
113
.. i18n:        The action name
114
114
.. i18n: **Action Type**
115
 
        .. i18n: Always 'ir.actions.act_window'
 
115
.. i18n:        Always 'ir.actions.act_window'
116
116
.. i18n: **View Ref**
117
 
        .. i18n: The view used for showing the object
 
117
.. i18n:        The view used for showing the object
118
118
.. i18n: **Model**
119
 
        .. i18n: The model of the object to post
 
119
.. i18n:        The model of the object to post
120
120
.. i18n: **Type of View**
121
 
        .. i18n: The type of view (Tree/Form)
 
121
.. i18n:        The type of view (Tree/Form)
122
122
.. i18n: **Domain Value**
123
 
        .. i18n: The domain that decreases the visible data with this view
 
123
.. i18n:        The domain that decreases the visible data with this view
124
124
 
125
125
**Action Name**
126
126
        The action name
165
165
 
166
166
The domains are written in python; list of tuples. The tuples have three elements;
167
167
 
168
 
    .. i18n: * the field on which the test must be done
169
 
    .. i18n: * the operator used for the test (<, >, =, like)
170
 
    .. i18n: * the tested value
 
168
.. i18n:     * the field on which the test must be done
 
169
.. i18n:     * the operator used for the test (<, >, =, like)
 
170
.. i18n:     * the tested value
171
171
 
172
172
    * the field on which the test must be done
173
173
    * the operator used for the test (<, >, =, like)
189
189
 
190
190
.. i18n: Actions are explained in more detail in section "Administration Modules - Actions". Here's the template of an action XML record :
191
191
.. i18n: ::
192
 
 
193
 
        <record model="ir.actions.act_window" id="action_id_1">
194
 
            <field name="name">action.name</field>
195
 
            <field name="view_id" ref="view_id_1"/>
196
 
            <field name="domain">["list of 3-tuples (max 250 characters)"]</field>
197
 
            <field name="context">{"context dictionary (max 250 characters)"}</field>
198
 
            <field name="res_model">Open.object</field>
199
 
            <field name="view_type">form|tree</field>
200
 
            <field name="view_mode">form,tree|tree,form|form|tree</field>
201
 
            <field name="usage">menu</field>
202
 
            <field name="target">new</field>
203
 
        </record>
204
 
 
205
 
        .. i18n: <record model="ir.actions.act_window" id="action_id_1">
206
 
            .. i18n: <field name="name">action.name</field>
207
 
            .. i18n: <field name="view_id" ref="view_id_1"/>
208
 
            .. i18n: <field name="domain">["list of 3-tuples (max 250 characters)"]</field>
209
 
            .. i18n: <field name="context">{"context dictionary (max 250 characters)"}</field>
210
 
            .. i18n: <field name="res_model">Open.object</field>
211
 
            .. i18n: <field name="view_type">form|tree</field>
212
 
            .. i18n: <field name="view_mode">form,tree|tree,form|form|tree</field>
213
 
            .. i18n: <field name="usage">menu</field>
214
 
            .. i18n: <field name="target">new</field>
215
 
        .. i18n: </record>
 
192
.. i18n: 
 
193
.. i18n:        <record model="ir.actions.act_window" id="action_id_1">
 
194
.. i18n:            <field name="name">action.name</field>
 
195
.. i18n:            <field name="view_id" ref="view_id_1"/>
 
196
.. i18n:            <field name="domain">["list of 3-tuples (max 250 characters)"]</field>
 
197
.. i18n:            <field name="context">{"context dictionary (max 250 characters)"}</field>
 
198
.. i18n:            <field name="res_model">Open.object</field>
 
199
.. i18n:            <field name="view_type">form|tree</field>
 
200
.. i18n:            <field name="view_mode">form,tree|tree,form|form|tree</field>
 
201
.. i18n:            <field name="usage">menu</field>
 
202
.. i18n:            <field name="target">new</field>
 
203
.. i18n:        </record>
 
204
 
 
205
Actions are explained in more detail in section "Administration Modules - Actions". Here's the template of an action XML record :
 
206
::
216
207
 
217
208
        <record model="ir.actions.act_window" id="action_id_1">
218
209
            <field name="name">action.name</field>
230
221
 
231
222
**Where**
232
223
 
233
 
    .. i18n: * **id** is the identifier of the action in the table "ir.actions.act_window". It must be unique.
234
 
    .. i18n: * **name** is the name of the action (mandatory).
235
 
    .. 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).
236
 
    .. 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.
237
 
    .. 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".
238
 
    .. i18n: * **res_model** is the name of the object on which the action operates.
239
 
    .. 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.
240
 
    .. i18n: * **view_mode** is only considered if view_type is form, and ignored otherwise. The four possibilities are :
241
 
          .. i18n: - **form,tree** : the view is first displayed as a form, the list view can be displayed by clicking the "alternate view button" ;
242
 
          .. i18n: - **tree,form** : the view is first displayed as a list, the form view can be displayed by clicking the "alternate view button" ;
243
 
          .. i18n: - **form** : the view is displayed as a form and there is no way to switch to list view ;
244
 
          .. i18n: - **tree** : the view is displayed as a list and there is no way to switch to form view.
 
224
.. i18n:     * **id** is the identifier of the action in the table "ir.actions.act_window". It must be unique.
 
225
.. i18n:     * **name** is the name of the action (mandatory).
 
226
.. 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).
 
227
.. 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.
 
228
.. 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".
 
229
.. i18n:     * **res_model** is the name of the object on which the action operates.
 
230
.. 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.
 
231
.. i18n:     * **view_mode** is only considered if view_type is form, and ignored otherwise. The four possibilities are :
 
232
.. i18n:           - **form,tree** : the view is first displayed as a form, the list view can be displayed by clicking the "alternate view button" ;
 
233
.. i18n:           - **tree,form** : the view is first displayed as a list, the form view can be displayed by clicking the "alternate view button" ;
 
234
.. i18n:           - **form** : the view is displayed as a form and there is no way to switch to list view ;
 
235
.. i18n:           - **tree** : the view is displayed as a list and there is no way to switch to form view.
245
236
 
246
237
    * **id** is the identifier of the action in the table "ir.actions.act_window". It must be unique.
247
238
    * **name** is the name of the action (mandatory).
260
251
 
261
252
(version 5 introduced **graph** and **calendar** views)
262
253
 
263
 
    .. i18n: * **usage** is used [+ ***TODO*** +]
264
 
    .. i18n: * **target** the view will open in new window like wizard.
 
254
.. i18n:     * **usage** is used [+ ***TODO*** +]
 
255
.. i18n:     * **target** the view will open in new window like wizard.
265
256
 
266
257
    * **usage** is used [+ ***TODO*** +]
267
258
    * **target** the view will open in new window like wizard.
275
266
Administration > Custom > Low Level > Base > Action > Window Actions
276
267
 
277
268
.. i18n: .. figure::  images/module_base_action_window.png
278
 
   .. i18n: :scale: 85
279
 
   .. i18n: :align: center
 
269
.. i18n:    :scale: 85
 
270
.. i18n:    :align: center
280
271
 
281
272
.. figure::  images/module_base_action_window.png
282
273
   :scale: 85
290
281
 
291
282
.. i18n: This action is declared in server/bin/addons/project/project_view.xml.
292
283
.. i18n: ::
293
 
 
294
 
    <record model="ir.actions.act_window" id="open_view_my_project">
295
 
        <field name="name">project.project</field>
296
 
        <field name="res_model">project.project</field>
297
 
        <field name="view_type">tree</field>
298
 
        <field name="domain">[('parent_id','=',False), ('manager', '=', uid)]</field>
299
 
        <field name="view_id" ref="view_my_project" />
300
 
    </record>
301
 
 
302
 
    .. i18n: <record model="ir.actions.act_window" id="open_view_my_project">
303
 
        .. i18n: <field name="name">project.project</field>
304
 
        .. i18n: <field name="res_model">project.project</field>
305
 
        .. i18n: <field name="view_type">tree</field>
306
 
        .. i18n: <field name="domain">[('parent_id','=',False), ('manager', '=', uid)]</field>
307
 
        .. i18n: <field name="view_id" ref="view_my_project" />
308
 
    .. i18n: </record>
 
284
.. i18n: 
 
285
.. i18n:     <record model="ir.actions.act_window" id="open_view_my_project">
 
286
.. i18n:         <field name="name">project.project</field>
 
287
.. i18n:         <field name="res_model">project.project</field>
 
288
.. i18n:         <field name="view_type">tree</field>
 
289
.. i18n:         <field name="domain">[('parent_id','=',False), ('manager', '=', uid)]</field>
 
290
.. i18n:         <field name="view_id" ref="view_my_project" />
 
291
.. i18n:     </record>
 
292
 
 
293
This action is declared in server/bin/addons/project/project_view.xml.
 
294
::
309
295
 
310
296
    <record model="ir.actions.act_window" id="open_view_my_project">
311
297
        <field name="name">project.project</field>
317
303
 
318
304
.. i18n: This action is declared in server/bin/addons/stock/stock_view.xml.
319
305
.. i18n: ::
320
 
 
321
 
    <record model="ir.actions.act_window" id="action_picking_form">
322
 
        <field name="name">stock.picking</field>
323
 
        <field name="res_model">stock.picking</field>
324
 
        <field name="type">ir.actions.act_window</field>
325
 
        <field name="view_type">form</field>
326
 
        <field name="view_id" ref="view_picking_form"/>
327
 
        <field name="context">{'contact_display': 'partner'}</field>
328
 
    </record>
329
 
 
330
 
    .. i18n: <record model="ir.actions.act_window" id="action_picking_form">
331
 
        .. i18n: <field name="name">stock.picking</field>
332
 
        .. i18n: <field name="res_model">stock.picking</field>
333
 
        .. i18n: <field name="type">ir.actions.act_window</field>
334
 
        .. i18n: <field name="view_type">form</field>
335
 
        .. i18n: <field name="view_id" ref="view_picking_form"/>
336
 
        .. i18n: <field name="context">{'contact_display': 'partner'}</field>
337
 
    .. i18n: </record>
 
306
.. i18n: 
 
307
.. i18n:     <record model="ir.actions.act_window" id="action_picking_form">
 
308
.. i18n:         <field name="name">stock.picking</field>
 
309
.. i18n:         <field name="res_model">stock.picking</field>
 
310
.. i18n:         <field name="type">ir.actions.act_window</field>
 
311
.. i18n:         <field name="view_type">form</field>
 
312
.. i18n:         <field name="view_id" ref="view_picking_form"/>
 
313
.. i18n:         <field name="context">{'contact_display': 'partner'}</field>
 
314
.. i18n:     </record>
 
315
 
 
316
This action is declared in server/bin/addons/stock/stock_view.xml.
 
317
::
338
318
 
339
319
    <record model="ir.actions.act_window" id="action_picking_form">
340
320
        <field name="name">stock.picking</field>
359
339
 
360
340
.. i18n: Here's an example of a .XML file that declares a wizard.
361
341
.. i18n: ::
362
 
 
363
 
        <?xml version="1.0"?>
364
 
        <terp>
365
 
            <data>
366
 
                 <wizard string="Employee Info"
367
 
                         model="hr.employee"
368
 
                         name="employee.info.wizard"
369
 
                         id="wizard_employee_info"/>
370
 
            </data>
371
 
        </terp>
372
 
 
373
 
        .. i18n: <?xml version="1.0"?>
374
 
        .. i18n: <terp>
375
 
            .. i18n: <data>
376
 
                 .. i18n: <wizard string="Employee Info"
377
 
                         .. i18n: model="hr.employee"
378
 
                         .. i18n: name="employee.info.wizard"
379
 
                         .. i18n: id="wizard_employee_info"/>
380
 
            .. i18n: </data>
381
 
        .. i18n: </terp>
 
342
.. i18n: 
 
343
.. i18n:        <?xml version="1.0"?>
 
344
.. i18n:        <terp>
 
345
.. i18n:            <data>
 
346
.. i18n:                 <wizard string="Employee Info"
 
347
.. i18n:                         model="hr.employee"
 
348
.. i18n:                         name="employee.info.wizard"
 
349
.. i18n:                         id="wizard_employee_info"/>
 
350
.. i18n:            </data>
 
351
.. i18n:        </terp>
 
352
 
 
353
Here's an example of a .XML file that declares a wizard.
 
354
::
382
355
 
383
356
        <?xml version="1.0"?>
384
357
        <terp>
396
369
 
397
370
.. i18n: also you can add wizard in menu using following xml entry
398
371
.. i18n: ::
399
 
 
400
 
    <?xml version="1.0"?>
401
 
    <terp>
402
 
         <data>
403
 
         <wizard string="Employee Info"
404
 
                 model="hr.employee"
405
 
                 name="employee.info.wizard"
406
 
                 id="wizard_employee_info"/>
407
 
         <menuitem
408
 
                 name="Human Resource/Employee Info"
409
 
                 action="wizard_employee_info"
410
 
                 type="wizard"
411
 
                 id="menu_wizard_employee_info"/>
412
 
         </data>
413
 
    </terp>
414
 
 
415
 
    .. i18n: <?xml version="1.0"?>
416
 
    .. i18n: <terp>
417
 
         .. i18n: <data>
418
 
         .. i18n: <wizard string="Employee Info"
419
 
                 .. i18n: model="hr.employee"
420
 
                 .. i18n: name="employee.info.wizard"
421
 
                 .. i18n: id="wizard_employee_info"/>
422
 
         .. i18n: <menuitem
423
 
                 .. i18n: name="Human Resource/Employee Info"
424
 
                 .. i18n: action="wizard_employee_info"
425
 
                 .. i18n: type="wizard"
426
 
                 .. i18n: id="menu_wizard_employee_info"/>
427
 
         .. i18n: </data>
428
 
    .. i18n: </terp>
 
372
.. i18n: 
 
373
.. i18n:     <?xml version="1.0"?>
 
374
.. i18n:     <terp>
 
375
.. i18n:          <data>
 
376
.. i18n:          <wizard string="Employee Info"
 
377
.. i18n:                  model="hr.employee"
 
378
.. i18n:                  name="employee.info.wizard"
 
379
.. i18n:                  id="wizard_employee_info"/>
 
380
.. i18n:          <menuitem
 
381
.. i18n:                  name="Human Resource/Employee Info"
 
382
.. i18n:                  action="wizard_employee_info"
 
383
.. i18n:                  type="wizard"
 
384
.. i18n:                  id="menu_wizard_employee_info"/>
 
385
.. i18n:          </data>
 
386
.. i18n:     </terp>
 
387
 
 
388
also you can add wizard in menu using following xml entry
 
389
::
429
390
 
430
391
    <?xml version="1.0"?>
431
392
    <terp>
456
417
 
457
418
.. i18n: Reports in Open ERP are explained in chapter "Reports Reporting". Here's an example of a XML file that declares a RML report :
458
419
.. i18n: ::
459
 
 
460
 
    <?xml version="1.0"?>
461
 
    <terp>
462
 
        <data>
463
 
        <report id="sale_category_print"
464
 
                string="Sales Orders By Categories"
465
 
                model="sale.order"
466
 
                name="sale_category.print"
467
 
                rml="sale_category/report/sale_category_report.rml"
468
 
                menu="True"
469
 
                auto="False"/>
470
 
         </data>
471
 
    </terp>
472
 
 
473
 
    .. i18n: <?xml version="1.0"?>
474
 
    .. i18n: <terp>
475
 
        .. i18n: <data>
476
 
        .. i18n: <report id="sale_category_print"
477
 
                .. i18n: string="Sales Orders By Categories"
478
 
                .. i18n: model="sale.order"
479
 
                .. i18n: name="sale_category.print"
480
 
                .. i18n: rml="sale_category/report/sale_category_report.rml"
481
 
                .. i18n: menu="True"
482
 
                .. i18n: auto="False"/>
483
 
         .. i18n: </data>
484
 
    .. i18n: </terp>
 
420
.. i18n: 
 
421
.. i18n:     <?xml version="1.0"?>
 
422
.. i18n:     <terp>
 
423
.. i18n:         <data>
 
424
.. i18n:         <report id="sale_category_print"
 
425
.. i18n:                 string="Sales Orders By Categories"
 
426
.. i18n:                 model="sale.order"
 
427
.. i18n:                 name="sale_category.print"
 
428
.. i18n:                 rml="sale_category/report/sale_category_report.rml"
 
429
.. i18n:                 menu="True"
 
430
.. i18n:                 auto="False"/>
 
431
.. i18n:          </data>
 
432
.. i18n:     </terp>
 
433
 
 
434
Reports in Open ERP are explained in chapter "Reports Reporting". Here's an example of a XML file that declares a RML report :
 
435
::
485
436
 
486
437
    <?xml version="1.0"?>
487
438
    <terp>
500
451
 
501
452
A report is declared using a **report tag** inside a "data" block. The different arguments of a report tag are :
502
453
 
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 Open ERP 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.
 
454
.. i18n:     * **id** : an identifier which must be unique.
 
455
.. i18n:     * **string** : the text of the menu that calls the report (if any, see below).
 
456
.. i18n:     * **model** : the Open ERP object on which the report will be rendered.
 
457
.. i18n:     * **rml** : the .RML report model. Important Note : Path is relative to addons/ directory.
 
458
.. 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.
 
459
.. 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
460
 
510
461
    * **id** : an identifier which must be unique.
511
462
    * **string** : the text of the menu that calls the report (if any, see below).