Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
29131 Ansichten

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

Avatar
Verwerfen
Beste Antwort

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
Verwerfen
Beste Antwort

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Feb. 24
24833
1
Aug. 23
2234
1
Juli 22
3054
2
März 22
2808
0
Nov. 20
6724