Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
3857 Tampilan

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.

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang

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

Post Terkait Replies Tampilan Aktivitas
3
Jul 24
2743
2
Jun 22
2891
0
Jul 17
4496
0
Jun 15
3953
0
Mar 15
4090