Skip to Content
Menu
This question has been flagged
2 Replies
3185 Views

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
Discard
Best Answer
/** @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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
5
Jan 23
13774
1
Sep 17
4447
2
Jul 17
4243
0
May 24
1695
1
Oct 23
1560