Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3972 มุมมอง

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?

Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ก.ค. 24
3055
2
มิ.ย. 22
3092
0
ก.ค. 17
4636
0
มิ.ย. 15
4160
0
มี.ค. 15
4200