Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3837 Widoki

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
3
lip 24
2718
2
cze 22
2884
0
lip 17
4488
0
cze 15
3947
0
mar 15
4080