Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

Hi, I am working on customizing the ListController in an Odoo module and have already applied a patch to the standard ListController. 

However, I now need to further extend this customized controller in a new module. I am not entirely sure about the best practices for extending an already patched controller. Here's the current implementation where it is initially patched the ListController:

import { ListController } from "@web/views/list/list_controller";

patch(ListController.prototype, "XXXX_controller", {
    // Custom implementations
});

Questions:

  1. What is the recommended approach to add additional functionality to this patched ListController?
  2. Should I create another patch, or is there a more efficient method to extend the existing patch?
  3. Are there any potential conflicts or best practices I should be aware of when patching an already extended controller in Odoo's JavaScript framework?

Any insights or examples would be greatly appreciated.

Awatar
Odrzuć
Najlepsza odpowiedź

In javascript, you can call parent method by using keyword super​. here is a reference https://stackoverflow.com/questions/11854958/how-to-call-a-parent-method-from-child-class-in-javascript 


so you can make a child method and place the parent method on the top of the child method

class Foo {
  static classMethod() {
    return 'hello';
  }
}

class Bar extends Foo {
  static classMethod() {
    return super.classMethod() + ', too';
  }
}

console.log(Bar.classMethod()); // 'hello, too'


Hope this help

Awatar
Odrzuć
Najlepsza odpowiedź

Hi, 

Please refer to this blog for Extend  Tree/List View in Odoo :

 Extend  Tree/List View in Odoo

Hope it helps

Awatar
Odrzuć
Autor

Hi, thanks for your answer.
Actually, I'd like to extend the controller, which has already extend the standard controller, ListController,
import { ListController } from "@web/views/list/list_controller";

If I created another controler to extend ListController, using patch function, it would override the existing extended controller. I'd like to keep the existing extended one.

Thanks

Powiązane posty Odpowiedzi Widoki Czynność
2
lip 23
3023
0
lut 23
2698
1
kwi 24
2103
0
sty 24
1675
1
wrz 23
3099