In Odoo, you can override the unlink() method to customize the delete functionality for a specific model. This method is called when a record is deleted.
2. Introduction
Enterprise
In Odoo, you can override the unlink() method to customize the delete
functionality for a specific model. This method is called when a record
is deleted.
3. Enterprise
● When we click on the delete button, the function unlink in the
respective model is executed
● If you want to add any additional functionality, when we are
deleting a record then you need to override the unlink function.
4. Enterprise
● Let’s check with an example
● We are going to raise an user error while deleting a record
based on a condition.
● Let’s say, we need to raise a user error for a product with cost
greater than 500 and prevent the deletion of that product
5. Enterprise
● To do this, inherit the model ‘product.product’ as shown in the image,
super the existing delete function, and write our piece of code in it
7. For More Info.
Check our company website for related
blogs and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com