Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
3844 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää

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

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
3
heinäk. 24
2723
2
kesäk. 22
2885
0
heinäk. 17
4490
0
kesäk. 15
3949
0
maalisk. 15
4082