콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
29373 화면

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
25131
1
8월 23
2384
1
7월 22
3193
2
3월 22
2983
0
11월 20
6946