Skip to Content
Menu
This question has been flagged
2 Replies
8789 Views

@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

Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

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.

Avatar
Discard
Related Posts Replies Views Activity
1
Mar 15
8142
1
May 19
9360
2
Jun 24
219
0
Jan 22
1568
0
Jul 19
3917