コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
29109 ビュー

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

アバター
破棄
関連投稿 返信 ビュー 活動
2
2月 24
24813
1
8月 23
2211
1
7月 22
3042
2
3月 22
2802
0
11月 20
6717