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

I want to raise an error if something specific happens and also show it in the UI. how can I do it?

Аватар
Отменить
Лучший ответ

You can raise any odoo exception which will show the error message in the popup.

Ex:

from odoo.exceptions import ValidationError

raise ValidationError("This is error message.")


Аватар
Отменить
Лучший ответ

UserError exception should be used in all cases where some action should not be allowed, when it goes against logic.

        if not self.checkout_ids:
            raise exceptions.UserError('Select at least one Checkout to send messages to.')
        if not self.message_body:
            raise exceptions.UserError('Write a message body to send.')

To Know More About different types of exceptions refer :

https://www.cybrosys.com/blog/raising-exceptions-odoo-13

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
февр. 24
24762
1
авг. 23
2176
1
июл. 22
3009
2
мар. 22
2773
0
нояб. 20
6686