Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Postgresql provides a more effective way called ON DELETE CASCADE referential action for a foreign key that allows you to delete data from child tables automatically when you delete the data from the parent table.
In openerp fields can add using ondelete='cascade'
Basically ondelete=cascade is Database functionality, not particularly odoo's.
If you wanted the related child records should get deleted automatically, when the parent record is deleted.
Take an example of Sale Order, if you want the Sale Order Lines should get deleted, when Sale order gets deleted.
for code example refer this : https://www.odoo.com/forum/help-1/question/delete-one2may-records-when-parent-record-is-deleted-30898
Hope this helps.
This is equivalent postgresql constraint ON DELETE CASCADE (similary RESTRICT). In postgresql documentation, see:
Restricting and cascading deletes are the two most common options. RESTRICT prevents deletion of a referenced row. NO ACTION means that if any referencing rows still exist when the constraint is checked, an error is raised; this is the default behavior if you do not specify anything. (The essential difference between these two choices is that NO ACTION allows the check to be deferred until later in the transaction, whereas RESTRICT does not.) CASCADE specifies that when a referenced row is deleted, row(s) referencing it should be automatically deleted as well. There are two other options: SET NULL and SET DEFAULT. These cause the referencing columns to be set to nulls or default values, respectively, when the referenced row is deleted. Note that these do not excuse you from observing any constraints. For example, if an action specifies SET DEFAULT but the default value would not satisfy the foreign key, the operation will fail.
Analogous to ON DELETE there is also ON UPDATE which is invoked when a referenced column is changed (updated). The possible actions are the same.
Here is a simple example
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 1/22/15, 5:53 AM|
|Seen: 4168 times|
|Last updated: 3/16/15, 8:10 AM|