Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How do I call a client action in return of a model function ?

By
PJ Soule
on 3/28/14, 8:03 AM 1,914 views

Hello everyone,

In my project, I had to create a web module (initally following the openerp tutorial) to show some specific information, from several different models (like a kanban view with trees inside).

For now, I display this "web view" using a menu, which calls the client action I created for my module, like this :

<menuitem id="main_results_menu" name="Results" />

<menuitem id="result_menu" name="Results"
    parent="main_results_menu" />

<record id="action_results_show" model="ir.actions.client">
    <field name="name">Results</field>
    <field name="tag">results.result</field>
</record>

<menuitem id="result_menu_show" name="Show results" parent="result_menu"
    action="action_results_show"/>

In my client code, I add the client action like this :

instance.web.client_actions.add('results.result', 'instance.rip.ResultsView');

Everything works fine, but the final goal is to present my "web view" after I execute some python code from a button in a classic form view.

The button executes some searches, then should show my view. I tried this, but I get an error ("Action manager can't handle action of type ir.action.client")

res = {
    'type': 'ir.action.client',
    'name':'Résultats',
    'tag':'results.result',
}
return res

Is there any way to achieve this ?

Thank you !

Any success with this yet? I'm running across the same problem.

Ryan Casey
on 4/2/14, 1:28 PM
1
Ryan Casey
On 4/2/14, 2:47 PM

I was having the same issue as you, and I just figured it out. There is no such type as "ir.action.client". It's "ir.actions.client".

So your code should be:

res = {
    'type': 'ir.actions.client',
    'name':'Résultats',
    'tag':'results.result',
}
return res

And this illustrates why using class properties and constants instead of "magic strings" is generally a good thing to do.

Hope this helps you!

Thank you for this answer. Finally, I changed my web module for a form widget, and I don't have any issues now,, Hope this answer can help anyone else !

PJ Soule
on 4/8/14, 8:00 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/28/14, 8:03 AM
Seen: 1914 times
Last updated: 3/16/15, 8:10 AM