Skip to Content
Menu
This question has been flagged
5 Replies
10491 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){
            alert("Error");
        }
        else{
            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
            self.do_action(action);

        }
    });
},

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 !

Avatar
Discard
Best Answer

Hi,

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

Avatar
Discard
Author

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.

Have you pass proper rs_id ?

Author

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 !

Best Answer

Generates an error when trying this solution

NS_ERROR_FAILURE:

Any other solution for this.

Avatar
Discard
Related Posts Replies Views Activity
1
Jul 24
401
1
Jul 23
3223
0
Mar 24
1982
1
Sep 22
4950
1
Mar 22
3817