跳至內容
選單
此問題已被標幟
2 回覆
10369 瀏覽次數

@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
9165
1
5月 19
10512
0
7月 25
13
2
6月 24
1099
0
1月 22
2372