The answer is to add or remove additional functionality we use overriding. For example if I want to check some constraints before creating, editing or deleting our record than we may use Odoo override methods.
There are basically three methods which we can override.
- Create
- Write
- Unlink
Create Method
The create method invoke every time when we click on "Create" or "New" button on Odoo form view and when we save the from using Save button.Below is the code snippet to override create method.
class Campus(models.Model):
_name='campus'
@api.model
def create(self,values):
campus_create = super(Campus,self).create(values)
return campus_create
Below is the code snippet to override write method.
class Campus(models.Model):
_name='campus'
@api.multi
def write(self,values):
campus_write = super(Campus,self).write(values)
return campus_write
Below is the code snippet to override unlink method.
class Campus(models.Model):
_name='campus'
@api.multi
def unlink(self,values):
campus_unlink = super(Campus,self).unlink()
return campus_unlink