Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
1084 Представления

I need to override a patch from a module that is part of the Enterprise edition. In this case, I only need to modify the patch of a method in JavaScript, but I don't see a way to modify just that patch without affecting the entire functionality. Is there a way to override or unpatch a specific patch? Or is there any workaround for this?

Аватар
Отменить

Hello, AFAIK you'd need to patch at least the method of that javascript part of the module

Лучший ответ

Hello Vicente de Orue,

 

In Odoo 17-18 we cannot unpatch a method, but we can override an existing patch from another module.

The patch() utility simply extends or replaces methods on the prototype, so to change an already patched method you just redefine it and optionally call the original one.

 

Here's a simple example showing how to override with the existing patch:

 

const oldMethod = Target.prototype.methodName;

 

patch(Target.prototype, "my_module", {

    methodName() {

        // your custom logic here

        return oldMethod.call(this, ...arguments); 

    },

});


If you have any questions, feel free to reach out to us

Hope this helps!


Thanks & Regards,

Email : odoo@aktivsoftware.com

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
июл. 25
776
2
июл. 25
1724
1
нояб. 24
1726
4
окт. 24
4268
0
апр. 23
1959