Override a Model’s Create Update and Delete Methods in Odoo

In Odoo, you can override a model’s create, update, and delete methods to change how the model behaves. This can be handy if you need to add extra validation or make other changes to how the data is stored and processed.

In this tutorial, we’ll show you how to override these methods and explain what each one does. Keep in mind that overriding the methods may cause your model to behave differently than expected, so always test your code thoroughly before deploying it in production.

class CustomModel(models.Model):

    name = fields.Char(string='Document Name')

    def create(self, values):
        res = super(CustomModel,self).create(values)
        return res

    def write(self, values):
        res = super(CustomModel, self).write(values)
        return res

    def unlink(self, values):
        res = super(CustomModel, self).unlink()
        return res
Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.