In Odoo, user actions can trigger different behaviors, such as opening a form view, launching a report, or displaying a wizard. We often need to redirect users to an external website, a download link, or even an internal route inside Odoo. This is where URL action comes into play. Redirect the user to a specific URL when they perform an action. Instead of rendering a view, it opens either an external website, an internal Odoo route, or a download link for files.
1. Open an External Website
Let’s see an example of opening an external website by adding a
Python method that returns an
“ir.actions.act_url” with a dynamic URL and linking it to a button in XML, such as a “
Visit Website” button on the partner form.
Python file
def action_open_website(self):
if not self.website:
return
return {
"type": "ir.actions.act_url",
"url": self.website,
"target": "new",
}
XML file
<button name="action_open_website"
type="object"
string="Visit Website"
class="btn-primary"/>
Here,
- type: Always “ir.actions.act_url” for URL redirection
- url: Can be a fixed link or a field value.
- Target: “new” which opens a new browser tab and “self” which opens inside Odoo, that is replaces the current page; “download” redirects to a download URL
2. Redirect to an Internal Odoo Record
Suppose you want to jump to a Sales Order linked to your model:
"url": f"/web#id={self.sale_order_id.id}&model=sale.order&view_type=form",3. Adding a Menu Item with URL
We can also create a menu item that redirects the user to a specific URL, such as the Odoo Apps Store.
<record model='ir.actions.act_url' id='action_third_party'>
<field name='name'>Third-Party Apps</field>
<field name='url'>https://apps.odoo.com/apps/modules</field>
</record>
<menuitem id="menu_third_party" parent="menu_apps" name="Third-Party Apps" sequence="20" action="action_third_party"/>
URL Actions in Odoo 19 are a simple feature that enhances user navigation and productivity. Whether you want to open an external website, jump directly to an internal record, or provide a quick download link, it makes it seamless.
To read more about How to Create and Use Client Actions in Odoo 19, refer to our blog How to Create and Use Client Actions in Odoo 19.