Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
29489 Zobrazení

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

Avatar
Zrušit
Nejlepší odpověď

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.")


Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
úno 24
25356
1
srp 23
2482
1
čvc 22
3256
2
bře 22
3070
0
lis 20
7019