تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3854 أدوات العرض

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
يوليو 24
2733
2
يونيو 22
2887
0
يوليو 17
4492
0
يونيو 15
3952
0
مارس 15
4087