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
This question has been flagged
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'
http://www.postgresql.org/docs/8.2/static/ddl-constraints.html
The available options are documented here: http://www.postgresql.org/docs/8.2/static/sql-createtable.html.
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
Hello LIBU,
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.
Regards,
Bharat
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up