Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
5 Vastaukset
11603 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää

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

Tekijä

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.

Paras vastaus

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
maalisk. 15
4991
1
maalisk. 15
10121
1
lokak. 22
14538
0
marrask. 18
10705
0
syysk. 23
2263