This blog describes different types of actions in Odoo 16. The user performs actions, and the system reacts based on the user’s actions. These responses are also called actions.
Odoo 16 has six actions
1. Server Actions (ir.actions.server)
2. Client Actions (ir.actions.client)
3. Automatic Actions (ir.cron)
4. URL Actions (ir.actions.act_url)
5. Report Actions (ir.actions.report)
6. Window Actions ( ir.actions.act_window )
These actions are stored in the database and are returned directly as a dictionary when you call the methods associated with them, such as button methods.
1. Server Action(ir.actions.server)
<record model="ir.actions.server" id="print_instance">
<field name="name">Res Partner Server Action</field>
<field name="model_id" ref="model_res_partner"/>
<field name="state">code</field>
<field name="code">
raise Warning(record.name)
</field>
</record>
<record model="ir.actions.server" id="print_instance"> <field name="name">Res Partner Server Action</field> <field name="model_id" ref="model_res_partner"/> <field name="state">code</field> <field name="code"> if record.some_condition(): action = { "type": "ir.actions.act_window", "view_mode": "form", "res_model": record._name, "res_id": record.id, } </field></record>
2. Client Action( ir.actions.client)
{
"type": "ir.actions.client",
"tag": "pos.ui"
}
3. Automated Action( ir.cron)
model.<method_name>()
4. URL Action(ir.actions.act_url)
{
"type": "ir.actions.act_url",
"url": "https://odoo.com",
"target": "self",
}
<record id="action_website" model="ir.actions.act_url">
<field name="name">Website</field>
<field name="url">https://odoo.com</field>
<field name="target">self</field>
</record>
5. Report Action( ir.actions.report)
<record id="pos_invoice_report" model="ir.actions.report">
<field name="name">Invoice</field>
<field name="model">pos.order</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">point_of_sale.report_invoice</field>
<field name="print_report_name">'Invoice - %s' % (object.name)</field>
</record>
6. Window Action(ir.actions.act_window)
{
"type": "ir.actions.act_window",
"res_model": "product.product",
"views": [[False, "form"]],
"res_id": a_product_id,
"target": "new",
}
<record model="ir.actions.act_window.view" id="test_action_tree">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_test_tree"/>
<field name="act_window_id" ref="test_action"/>
</record>
Thisis all about the type of actions in Odoo 16.