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

How can we inherit method of class in js 
I have to inherit one of the method of FormController from web/../src/views/...js. then how can i inherit this method into custom module. method name - getActionMenuItems

الصورة الرمزية
إهمال
أفضل إجابة
/** @odoo-module **/
import { FormController } from "@web/views/form/form_controller";
import {patch} from "@web/core/utils/patch";

patch(FormController.prototype, "CustomFormController", {

​getActionMenuItems() {
​//your code
​​this._super.apply(this, arguments);
​//your code
​}

});



الصورة الرمزية
إهمال
أفضل إجابة

Hi,

Please refer to the code below. It will give you an idea on how to inherit OWL Js:


/** @odoo-module **/


import { FormController } from "@web/views/form/form_controller";


export class CustomFormController extends FormController {


getActionMenuItems() {

const superVals = super.getActionMenuItems();

// Your code

return superVals;


}


export const CustomFormView = {

...formView,

Controller: CustomFormController,

};


registry.category("views").add("custom_form", CustomFormView);


Hope it helps

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
5
يناير 23
14210
1
سبتمبر 17
4707
2
يوليو 17
4505
0
مايو 24
2004
1
أكتوبر 23
1810