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

@api.multi 

 def _target_achieve(self):

 if self._origin.id:

print("==============I RUN") 

else:

raise exceptions.ValidationError('No ID')


error is 


  if self._origin.id:
AttributeError: 'sale.promotion.rule' object has no attribute '_origin'

why else statement is not run 

where i'm wrong

アバター
破棄
最善の回答

Hi,

Try to make like this


@api.multi
def _target_achieve(self):
    if self._origin:
        if self._origin.id:
            print("==============I RUN")
        else:
            raise exceptions.ValidationError('No ID') 


Thanks

アバター
破棄
最善の回答

If you use "_target_achieve" function in compute like:

... compute="_target_achieve"...

You won't be able to use "self._origin".

This is what I figured out after trying everything.

アバター
破棄
関連投稿 返信 ビュー 活動
1
3月 15
9167
1
5月 19
10514
0
7月 25
13
2
6月 24
1099
0
1月 22
2373