Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3849 Vizualizări

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.

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează

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

Related Posts Răspunsuri Vizualizări Activitate
3
iul. 24
2733
2
iun. 22
2887
0
iul. 17
4492
0
iun. 15
3952
0
mar. 15
4087