Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3843 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 7 24
2723
2
thg 6 22
2885
0
thg 7 17
4490
0
thg 6 15
3949
0
thg 3 15
4082