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, ...
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, ...
21
.. i18n: There are different types of simple actions:
24
There are different types of simple actions:
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
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
43
.. i18n: The actions are used for the following events;
46
The actions are used for the following events;
48
.. i18n: * User connection,
49
.. i18n: * The user double-clicks on the menu,
50
.. i18n: * The user clicks on the icon 'print' or 'action'.
54
* The user double-clicks on the menu,
55
* The user clicks on the icon 'print' or 'action'.
57
.. i18n: Example of events
58
.. i18n: -----------------
64
.. i18n: In OpenERP, all the actions are described and not configured. Two examples:
67
In OpenERP, all the actions are described and not configured. Two examples:
69
.. i18n: * Opening of a window when double-clicking in the menu
70
.. i18n: * User connection
73
* Opening of a window when double-clicking in the menu
76
.. i18n: Opening of the menu
77
.. i18n: +++++++++++++++++++
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.
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.
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.
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.
99
.. i18n: User connection
100
.. i18n: +++++++++++++++
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.
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.
111
.. i18n: The steps are:
116
.. i18n: 1. Reading of a user file to obtain ACTION_ID
117
.. i18n: 2. Reading of the action and execution of this one
120
1. Reading of a user file to obtain ACTION_ID
121
2. Reading of the action and execution of this one
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
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
147
Always 'ir.actions.act_window'
149
The view used for showing the object
151
The model of the object to post
153
The type of view (Tree/Form)
155
The domain that decreases the visible data with this view
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.
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.
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').
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').
178
.. i18n: This parameter allows you to regulate which resources are visible in a selected view.(restriction)
181
This parameter allows you to regulate which resources are visible in a selected view.(restriction)
183
.. i18n: For example, in the invoice case, you can define an action that opens a view that shows only invoices not paid.
186
For example, in the invoice case, you can define an action that opens a view that shows only invoices not paid.
188
.. i18n: The domains are written in python; list of tuples. The tuples have three elements;
191
The domains are written in python; list of tuples. The tuples have three elements;
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
198
* the field on which the test must be done
199
* the operator used for the test (<, >, =, like)
202
.. i18n: For example, if you want to obtain only 'Draft' invoice, use the following domain; [('state','=','draft')]
205
For example, if you want to obtain only 'Draft' invoice, use the following domain; [('state','=','draft')]
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.
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.
212
.. i18n: Window Action
213
.. i18n: -------------
219
.. i18n: Actions are explained in more detail in section "Administration Modules - Actions". Here's the template of an action XML record :
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>
235
Actions are explained in more detail in section "Administration Modules - Actions". Here's the template of an action XML record :
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>
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.
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.
282
.. i18n: (version 5 introduced **graph** and **calendar** views)
285
(version 5 introduced **graph** and **calendar** views)
287
.. i18n: * **usage** is used [+ ***TODO*** +]
288
.. i18n: * **target** the view will open in new window like wizard.
291
* **usage** is used [+ ***TODO*** +]
292
* **target** the view will open in new window like wizard.
294
.. i18n: They indicate at the user that he has to open a new window in a new 'tab'.
297
They indicate at the user that he has to open a new window in a new 'tab'.
299
.. i18n: Administration > Custom > Low Level > Base > Action > Window Actions
302
Administration > Custom > Low Level > Base > Action > Window Actions
304
.. i18n: .. figure:: images/module_base_action_window.png
306
.. i18n: :align: center
309
.. figure:: images/module_base_action_window.png
313
.. i18n: Examples of actions
314
.. i18n: +++++++++++++++++++
320
.. i18n: This action is declared in server/bin/addons/project/project_view.xml.
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" />
332
This action is declared in server/bin/addons/project/project_view.xml.
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" />
343
.. i18n: This action is declared in server/bin/addons/stock/stock_view.xml.
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>
356
This action is declared in server/bin/addons/stock/stock_view.xml.
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>
375
.. i18n: Wizard Action
376
.. i18n: -------------
382
.. i18n: Here's an example of a .XML file that declares a wizard.
385
.. i18n: <?xml version="1.0"?>
388
.. i18n: <wizard string="Employee Info"
389
.. i18n: model="hr.employee"
390
.. i18n: name="employee.info.wizard"
391
.. i18n: id="wizard_employee_info"/>
396
Here's an example of a .XML file that declares a wizard.
399
<?xml version="1.0"?>
402
<wizard string="Employee Info"
404
name="employee.info.wizard"
405
id="wizard_employee_info"/>
409
.. i18n: A wizard is declared using a wizard tag. See "Add A New Wizard" for more information about wizard XML.
412
A wizard is declared using a wizard tag. See "Add A New Wizard" for more information about wizard XML.
414
.. i18n: also you can add wizard in menu using following xml entry
417
.. i18n: <?xml version="1.0"?>
420
.. i18n: <wizard string="Employee Info"
421
.. i18n: model="hr.employee"
422
.. i18n: name="employee.info.wizard"
423
.. i18n: id="wizard_employee_info"/>
425
.. i18n: name="Human Resource/Employee Info"
426
.. i18n: action="wizard_employee_info"
427
.. i18n: type="wizard"
428
.. i18n: id="menu_wizard_employee_info"/>
433
also you can add wizard in menu using following xml entry
436
<?xml version="1.0"?>
439
<wizard string="Employee Info"
441
name="employee.info.wizard"
442
id="wizard_employee_info"/>
444
name="Human Resource/Employee Info"
445
action="wizard_employee_info"
447
id="menu_wizard_employee_info"/>
451
.. i18n: Report Action
452
.. i18n: -------------
458
.. i18n: Report declaration
459
.. i18n: ++++++++++++++++++
465
.. i18n: Reports in OpenERP are explained in chapter "Reports Reporting". Here's an example of a XML file that declares a RML report :
468
.. i18n: <?xml version="1.0"?>
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"
477
.. i18n: auto="False"/>
482
Reports in OpenERP are explained in chapter "Reports Reporting". Here's an example of a XML file that declares a RML report :
485
<?xml version="1.0"?>
488
<report id="sale_category_print"
489
string="Sales Orders By Categories"
491
name="sale_category.print"
492
rml="sale_category/report/sale_category_report.rml"
498
.. i18n: A report is declared using a **report tag** inside a "data" block. The different arguments of a report tag are :
501
A report is declared using a **report tag** inside a "data" block. The different arguments of a report tag are :
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.
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.