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

Hello community,
I have a problem with the overload of the create() and write() methods.
Let me explain.

My custom module inherits from a custom module in which I have no rights to modify the code. These 2 modules overload the create and write methods. On the other hand, I don't like the custom module overloads. So I want to override these method overloads so that my new overloads in my custom module are taken into account. How can I do it?

I tried not to call super(), it works but it doesn't call other write and create method() from all other modules. Do you have any idea please? thank you in advance

Avatar
Discard

You can skip all the models and call the base Model

BaseMetaModel = self.env.registry['base']
super(BaseMetaModel, self).create(values)

I can't post an answer, anyone knows why?

Best Answer

Here you can use monkey patch.

For more information please check this discussion.

https://youtu.be/8K1o9Xhk4gY

Avatar
Discard
Best Answer

Hello

You can do something like this:

from odoo.addons.stock.models.stock_picking import Picking
def button_validate(self):
    #your code
    return
Picking.button_validate = button_validate


Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
263
1
Oct 24
331
4
Oct 24
324
2
Oct 24
361
2
Dec 24
666