Actions - Odoo 11.0 Documentation
Actions - Odoo 11.0 Documentation
0 documentation
type
name
False
A string
if a client action
(https://www.odoo.com/documentation/11.0/reference/actions.
html#reference-actions-client) matches, interpret as a client
action’s tag, otherwise treat as a number
A number
read the corresponding action record from the database, may be
a database identifier or an external id
(https://www.odoo.com/documentation/11.0/glossary.html#ter
m-external-id)
A dictionary
treat as a client action descriptor and execute
res_model
views
res_id (optional)
if the default view is form , specifies the record to load (otherwise
a new record should be created)
search_view_id (optional)
(id, name) pair, id is the database identifier of a specific search
view to load for the action. Defaults to fetching the default
search view for the model
target (optional)
whether the views should be open in the main content area
(current ), in full screen mode (fullscreen ) or in a dialog/popup
(new ). Use main instead of current to clear the breadcrumbs.
Defaults to current .
context (optional)
additional context data to pass to the views
domain (optional)
filtering domain to implicitly add to all view search queries
limit (optional)
number of records to display in lists by default. Defaults to 80 in
the web client
auto_search (optional)
whether a search should be performed immediately after loading
the default view. Defaults to True
"type": "ir.actions.act_window",
"res_model": "res.partner",
"type": "ir.actions.act_window",
"res_model": "product.product",
"res_id": a_product_id,
"target": "new",
view_mode
view_ids
M2M1
(https://www.odoo.com/documentation/11.0/reference/actions.
html#notquitem2m) to view objects, defines the initial content of
views
view_id
specific view added to the views list in case its type is part of the
view_mode list and not already filled by one of the views in view_ids
These are mostly used when defining actions from Data Files
(https://www.odoo.com/documentation/11.0/reference/data.ht
ml#reference-data):
<field name="res_model">some.model</field>
<field name="view_mode">graph</field>
</record>
will use the “my_specific_view” view even if that’s not the default
view for the model.
if view_id is defined and its type isn’t already filled, append its
(id, type)
url
target
"type": "ir.actions.act_url",
"url": "http://odoo.com",
"target": "self",
will replace the current content section by the Odoo home page.
id
context (optional)
model_id
condition (optional)
Valid action types ( state field) are extensible, the default types
are:
code
code
<field name="code">
raise Warning(object.name)
</field>
</record>
The code segment can define a variable called action , which will
be returned to the client as the next action to execute:
<field name="code">
if object.some_condition():
action = {
"type": "ir.actions.act_window",
"view_mode": "form",
"res_model": object._name,
"res_id": object.id,
</field>
</record>
will ask the client to open a form for the record if it fulfills some
condition
This tends to be the only action type created from data files
(https://www.odoo.com/documentation/11.0/reference/data.ht
ml#reference-data), other types aside from multi
(https://www.odoo.com/documentation/11.0/reference/actions.
html#reference-actions-server-multi) are simpler than Python
code to define from the UI, but not from data files
(https://www.odoo.com/documentation/11.0/reference/data.ht
ml#reference-data).
current
other
expression
write_expression
fields_lines
see object_create
(https://www.odoo.com/documentation/11.0/reference/actions.
html#reference-actions-server-object-create)
crud_model_id
see object_create
(https://www.odoo.com/documentation/11.0/reference/actions.
html#reference-actions-server-object-create)
ref_object
see object_create
(https://www.odoo.com/documentation/11.0/reference/actions.
html#reference-actions-server-object-create)
multi
client_action
Evaluation context
model
object , obj
cr
user
context
execution context
Warning
name (mandatory)
model (mandatory)
report_type (mandatory)
report_name
the name of your report (which will be the name of the PDF
output)
groups_id
Many2many
(https://www.odoo.com/documentation/11.0/reference/orm.htm
l#odoo.fields.Many2many) field to the groups allowed to
view/use the current report
paperformat_id
Many2one
(https://www.odoo.com/documentation/11.0/reference/orm.htm
l#odoo.fields.Many2one) field to the paper format you wish to
use for this report (if not specified, the company format will be
used)
attachment_use
if set to True , the report is only generated once the first time it is
requested, and re-printed from the stored report afterwards
instead of being re-generated every time.
Can be used for reports which must only be generated once (e.g.
for legal reasons)
attachment
python expression that defines the name of the report; the record
is accessible as the variable object
tag
params (optional)
target (optional)
whether the client action should be open in the main content
area (current ), in full screen mode (fullscreen ) or in a
dialog/popup (new ). Use main instead of current to clear the
breadcrumbs. Defaults to current .
"type": "ir.actions.client",
"tag": "pos.ui"
tells the client to start the Point of Sale interface, the server has
no idea how the POS interface works.
[1]
(https://www.odoo.com/documentation/11.0/reference/actions.html#id1)
technically not an M2M: adds a sequence field and may be composed of
just a view type, without a view id.