Odoo Help


How to call an ir_act_window from a form widget ?

PJ Soule
on 4/8/14, 9:01 AM 3,581 views

Hello everyone.

I created a form widget, which has a button that executes a model python function then call a window action to show another form.

The button javascript code is like this :

validate: function(solution_id)
    var self = this;
    var model = new instance.web.Model("mod.flight.result");
    model.call("confirm_selection", [solution_id]).then(function(result){
        if (result == false){
            var action = {
                    type: 'ir.actions.act_window',
                    res_model: 'mod.flight',
                    view_mode: 'form',
                    view_type: 'form',
                    views: [[false, 'form']],
                    target: 'current',
                    res_id: result
            // self.do_action accepts the action parameter and opens the new view


My function on the server returns the id of the element I want to show.

My issue is that when I call the self.do_action() function, I get the error :

Traceback (most recent call last):
  File "/home/pj/dev/b2b-8/server/openerp/http.py", line 362, in dispatch
    response["result"] = self._call_function(**self.params)
  File "/home/pj/dev/b2b-8/server/openerp/http.py", line 223, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/pj/dev/b2b-8/server/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/pj/dev/b2b-8/server/openerp/http.py", line 220, in checked_call
    return self.endpoint(*a, **kw)
  File "/home/pj/dev/b2b-8/server/openerp/http.py", line 559, in __call__
    return self.method(*args, **kw)
  File "/home/pj/dev/b2b-8/server/openerp/http.py", line 266, in response_wrap
    response = f(*args, **kw)
  File "/home/pj/dev/b2b-8/server/openerp/addons/web/controllers/main.py", line 1226, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/home/pj/dev/b2b-8/server/openerp/addons/web/controllers/main.py", line 1207, in _call_kw
    names = dict(request.session.model(model).name_get(args[0], **kwargs))
  File "/home/pj/dev/b2b-8/server/openerp/http.py", line 656, in proxy
    result = meth(cr, request.uid, *args, **kw)
  File "/home/pj/dev/b2b-8/server/openerp/osv/orm.py", line 1978, in name_get
    load='_classic_write', context=context)]
  File "/home/pj/dev/b2b-8/server/openerp/osv/orm.py", line 3279, in read
    select = map(lambda x: isinstance(x, dict) and x['id'] or x, select)
  File "/home/pj/dev/b2b-8/server/openerp/osv/orm.py", line 3279, in <lambda>
    select = map(lambda x: isinstance(x, dict) and x['id'] or x, select)
KeyError: 'id'

I really don't know where do this error comes from. My action seems to be well formatted, my res_id value is correct. Don't have any clue..

Any idea about this error ?

I'm working on the trunk version of openerp by the way (version 8).

Thank you !


Jagdish Panchal

--Jagdish Panchal--

| 5 4 6
Gandhinagar, India
--Jagdish Panchal--

OpenERP Developer

Jagdish Panchal
On 4/8/14, 9:16 AM


See this code is

    on_invite_follower: function (event) {
        var self = this;
        var action = {
            type: 'ir.actions.act_window',
            res_model: 'mail.wizard.invite',
            view_mode: 'form',
            view_type: 'form',
            views: [[false, 'form']],
            target: 'new',
            context: {
                'default_res_model': this.view.dataset.model,
                'default_res_id': this.view.datarecord.id,

This code given in 'Mail' module in addons check it

Hmm, I don't see any real difference between this code and mine, except for the context. But I managed to find why I've got an issue : the action manager doesn't seem to like my res_id.

If I don't put a res_id into my action, everything works fine, but the form is in create mode, which isn't what I want.

I think the way I pass my id to the action is wrong, I'm going to see why.

I tried using the context to pass the res_id, but I get the form in create mode too.

Thank you for your answer though, It helps me understand the issue.

PJ Soule
on 4/8/14, 9:39 AM

Have you pass proper rs_id ?

Jagdish Panchal
on 4/8/14, 9:40 AM

Ok, my bad.. I just forgot to relaunch my openerp server after I managed to change my python function return. Everything works fine with my original javascript code.

Thank you Jack !

PJ Soule
on 4/8/14, 9:59 AM
Khatri Jeenit
On 7/18/16, 4:33 AM

Generates an error when trying this solution


Any other solution for this.

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 4/8/14, 9:01 AM
Seen: 3581 times
Last updated: 7/18/16, 4:33 AM