تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
5 الردود
11726 أدوات العرض

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
مارس 15
5089
1
مارس 15
10229
1
أكتوبر 22
14662
0
نوفمبر 18
10814
0
سبتمبر 23
2432