
Learn to create URL actions in Odoo to open specific links and records directly from the interface. Improve navigation with URL actions.
In Odoo, URL actions provide a way to navigate users directly to specific URLs from within the application. This feature is helpful for opening internal or external links, allowing users to access external resources, web pages, or specific Odoo records seamlessly.
To define a URL action, you return a dictionary specifying the URL and action type. Here’s an example:
def action_open_record(self):
return {
'type': 'ir.actions.act_url',
'url': '/web#id=%s&view_type=form&model=custom.model' % self.id,
'target': 'self'
}
In this example:
To make this action accessible, you can add a button in your view XML file:
<button name="action_open_record" type="object" string="Open Record" class="btn-primary"/>
This button triggers the action_open_record method, which opens the form view of the specific record in the same tab. Add this button to the desired view to make it available to users.
By implementing URL actions in Odoo, you can streamline navigation within the system and link users directly to necessary pages, both within and outside of Odoo. URL actions provide an efficient way to enhance the user experience by making information and resources easily accessible.
Your email address will not be published. Required fields are marked *