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

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

To override a model create/update/delete functions in Odoo, you can create a new module that extends the original model and adds the new functionality. 

Overriding these functions is simple. Here are the codes:

class CustomModel(models.Model):
    _name='custom.info'    

    name = fields.Char('name')

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

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

    @api.multi
    def unlink(self, values):
        res = super(CustomModel, self).unlink()
        return res

Leave a Comment

Your email address will not be published. Required fields are marked *


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.

Close