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

I want to store only one record in a table and I have to show an error message when clicked on create button in tree view , if tried to enter another record . How to over ride the create button and display custom error message.

아바타
취소
베스트 답변

Hi,

You can try like this,

@api.model
def create(self, vals):
existing_records = self.search([])
if len(existing_records) >1:
raise ValidationError(_("Cannot Create More Than 1 Record"))
res = super(ClassName, self).create(vals)
return res

Thanks

아바타
취소

Hi Niyas, how to add a new button after the create button in Odoo16?

관련 게시물 답글 화면 활동
3
7월 24
2730
2
6월 22
2885
0
7월 17
4492
0
6월 15
3950
0
3월 15
4086