跳至内容
菜单
此问题已终结
5 回复
11656 查看

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!

形象
丢弃
最佳答案

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

编写者

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.

最佳答案

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.

形象
丢弃
相关帖文 回复 查看 活动
1
3月 15
5032
1
3月 15
10153
1
10月 22
14598
0
11月 18
10736
0
9月 23
2305