Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
5 Antwoorden
11599 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer

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

Auteur

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.

Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
mrt. 15
4991
1
mrt. 15
10121
1
okt. 22
14538
0
nov. 18
10705
0
sep. 23
2263