콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
2701 화면

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?

아바타
취소
베스트 답변

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:

ORM API — Odoo 15.0 documentation

아바타
취소
작성자 베스트 답변

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)?

아바타
취소
관련 게시물 답글 화면 활동
0
11월 22
2191
3
11월 24
29955
3
9월 24
46904
1
8월 24
1821
1
9월 23
3243