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

[JavaScript] Can't call _super() in an asynchronous call

By
Thanh Loyal
on 3/4/16, 11:43 PM 610 views

Hello, 

I modify a view like bellow:

local.ScKanbanGroup = instance.web_kanban.KanbanGroup.include({
init: function (parent, records, group, dataset) {
var self = this;
var res_user = new openerp.web.Model('res.users');
res_user.call('get_picking_type_ids', null)
.then(function (response) {
// generate new records array base on response
self._super(parent, newRecords, group, dataset);
});
}, ...


I need to pass 'newRecords' to the parent init function but what I get is TypeError: self._super is not a function.

Please help.

Thank you!

1
Shawn Varghese
On 3/5/16, 5:16 AM

Your _super() call is inside the asynchronous part of the method.

You need to assign it to a different variable and then call that. Could you try this:

local.ScKanbanGroup = instance.web_kanban.KanbanGroup.include({
 init: function (parent, records, group, dataset) {
    var self = this;
    var _super=this._super.bind(this);
    var res_user = new openerp.web.Model('res.users');
    res_user.call('get_picking_type_ids', null)
    .then(function (response) {
     // generate new records array base on response
     _super(parent, newRecords, group, dataset);
     });         
},


The Javascript documentation on the Odoo website might provide more insight: https://www.odoo.com/documentation/9.0/howtos/web.html

Shawn Varghese
on 3/5/16, 5:18 AM

Thank you, but that doesn't work. Now I get this._super(...) is undefined.

Thanh Loyal
on 3/5/16, 7:36 AM

I tried that, it works.

mustafa
on 9/19/16, 10:27 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/4/16, 11:43 PM
Seen: 610 times
Last updated: 3/5/16, 5:16 AM