This question has been flagged
2 Replies
7822 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