Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
29772 Visualizzazioni

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

Avatar
Abbandona
Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
feb 24
25679
1
ago 23
2662
1
lug 22
3472
2
mar 22
3281
0
nov 20
7244