İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
29282 Görünümler

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

Avatar
Vazgeç
En İyi Yanıt

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
Vazgeç
En İyi Yanıt

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Şub 24
24990
1
Ağu 23
2331
1
Tem 22
3155
2
Mar 22
2931
0
Kas 20
6901