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

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
1696
0
1月 24
1269
4
5月 25
1057
2
5月 25
4089
3
4月 25
3948