Getting started with Client Action(ir.actions.client) in Odoo 13

Rameshwor Dhakal
Bajra Technologies Blog
2 min readApr 25, 2020

--

Before some time, we(our development team) were in trouble as there was no official documentation of ir.actions.client. Also, we didn’t find any blogs and resources in the forum to start up with this thing. Despite this trouble, our very own Subash Basnet was ready to start away and figured out some way to render the Client Action.

So now, I am writing this so that you may not get into the trouble that we had faced.

Now to get started, let’s return an ir.actions.client from a python method. You can define client action in XML too (like as defining act_window). Here, I am going to return the client action in a dialog.

Let’s define just two input fields to capture the data. You can define any number of input fields or a form to capture the data.

The below JS code renders the above-defined template in a dialog. While adding the widget in the registry, the name should be the same as the tag defined while returning the client action. Here, I assume that you know how to define widgets in JS and it’s lifecycle. If you want to know about it, view it here.

In the above code, I had overwritten the HTML of “modal-body” class as I had returned the client action as target new. If you want to render client action in the current window, you have to overwrite the HTML of the “o_content” class. Because of returning my client action as target new, I don’t need the control panel items like breadcrumb. If you want to render a control panel, you can update the control panel through the start function.

Proper comments are added to the code in each section so that you get to know the function of that code. Hope you understood.

Don’t forget to include the above JS file into web.assets_backend.

And at last, include the above assets file and qweb template to manifest.

After running the above code, if you trigger the return_client_action method defined above, you will see a dialog with what we have defined as below.

--

--

Software Engineer, a tech enthusiast, an open-source lover, and a good human being.