跳至内容
菜单
此问题已终结
2 回复
10209 查看

@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
9014
1
5月 19
10386
0
7月 25
13
2
6月 24
987
0
1月 22
2233