How to Override Odoo Functions: Model’s Create/Update/Delete

There are 3 core methods which are related to a record. They are Create, Write, and Unlink. You can call them Create, Update, and Delete.

Overriding these functions are simple.

class CustomModel(models.Model):

    name = fields.Char('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

Leave a Comment

Your email address will not be published.

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.