Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
3614 Visninger

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

Avatar
Kassér
Bedste svar
/** @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
​}

});



Avatar
Kassér
Bedste svar

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

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
5
jan. 23
14199
1
sep. 17
4701
2
jul. 17
4487
0
maj 24
1992
1
okt. 23
1805