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

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
24820
1
серп. 23
2218
1
лип. 22
3044
2
бер. 22
2803
0
лист. 20
6719