Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
29162 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.พ. 24
24857
1
ส.ค. 23
2243
1
ก.ค. 22
3069
2
มี.ค. 22
2830
0
พ.ย. 20
6768