Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
29073 Vizualizări

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

Imagine profil
Abandonează
Cel mai bun răspuns

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


Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
feb. 24
24766
1
aug. 23
2176
1
iul. 22
3013
2
mar. 22
2778
0
nov. 20
6688