Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
3826 Представления

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
2703
2
июн. 22
2874
0
июл. 17
4480
0
июн. 15
3944
0
мар. 15
4070