Our product DB is a list of comics. We made a custom model for the publishers of these comics. A custom field in the product detail view has been made to add (or create) a publisher to a comic. When created in the product detail view, the new publisher correctly appears in the publishers' list (for which we created an extra menu). However, we are able to delete entries (or values) in this list, even when they are in use in a product. How can we avoid deleting values from this model when they are in use by a (or more) product?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Бухоблік
- Склад
- PoS
- Project
- MRP
Це запитання позначене
2
Відповіді
2485
Переглядів
You have used the Many2one field to link the product with publisher so you can add the below attribute to that field
ondelete='restrict'
For example:
publisher_id = fields.Many2one('publisher', required=True, ondelete="restrict")
Reference:
Thnx.
I'm fairly new to Odoo. I created this model from the backend (Odoo 15 enterprise). Where would I have to write this line of code (or similar)?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
РеєстраціяRelated Posts | Відповіді | Переглядів | Дія | |
---|---|---|---|---|
|
0
лист. 22
|
2088 | ||
|
3
лист. 24
|
29662 | ||
|
3
вер. 24
|
46605 | ||
Self hosting Odoo custom
Вирішено
|
|
1
серп. 24
|
1687 | |
|
1
вер. 23
|
3066 |