Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
3997 Ansichten

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
Verwerfen
Beste Antwort

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
Verwerfen

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

Verknüpfte Beiträge Antworten Ansichten Aktivität
3
Juli 24
3085
2
Juni 22
3104
0
Juli 17
4654
0
Juni 15
4167
0
März 15
4203