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='custom.model' name = fields.Char(string='Document 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