This question has been flagged
5 Replies
9601 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!

Avatar
Discard
Best Answer

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);
     });         
},


Avatar
Discard

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

Author

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

I tried that, it works.

This is working in V12 too

The Shawn Varghese response put me in the right direction. Works for Odoo 13 as well.

Search this line:
"When overriding a method using inheritance, you can use this._super() to call the original method:"

Explains two code examples for the use of 'this._super()'

Thanks, works perfectly.

Best Answer

what is the use of this._super() and this._super.apply(). can you give me the definition.

In which case, we can use this._super() and this._super.apply().

what is the difference between include() and extend() odoo javascript.

Avatar
Discard