Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
3859 Переглядів

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.

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити

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

Related Posts Відповіді Переглядів Дія
3
лип. 24
2747
2
черв. 22
2891
0
лип. 17
4499
0
черв. 15
3953
0
бер. 15
4091