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

i am adding a Computed field through Technical -> Models

i want to check some values but i can't use UserError because it needs to import related module.

when i am using: 

from odoo.exceptions import UserError

it is throwing error on above mentioned line.

i think this is not allowing to use it, is there any other way to show the value like UserError etc. ? and what if i want to import any other library module? 

please help.

regards


아바타
취소
베스트 답변

Hi,

You are right, it's not allowed do import other libraries from UI, but some of them are already imported, like datetime or UserError.
So you can just write UserError("Needed value") and get a result. It working also in scheduled actions.

아바타
취소
베스트 답변

If you are doing from the UI side you don't need to import it just use
raise UserError('Hellooooo')


아바타
취소
작성자

thank you @Jaiswal but it is showing error as below:

ValueError: <class 'NameError'>: "name 'UserError' is not defined"

i can't add screenshot in Comment.

작성자 베스트 답변

i added code as below:

abcd = self._origin.id

    raise UserError(f'{abcd}')


here is screenshot of error:

regards

아바타
취소
관련 게시물 답글 화면 활동
2
9월 24
2415
0
1월 24
1779
1
6월 25
15295
4
5월 25
2486
2
5월 25
5844