Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
3618 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
5
ม.ค. 23
14199
1
ก.ย. 17
4701
2
ก.ค. 17
4487
0
พ.ค. 24
1992
1
ต.ค. 23
1806