Skip to Content
Menú
This question has been flagged
2 Respostes
10374 Vistes

@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
Descartar
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
Descartar
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
Descartar
Related Posts Respostes Vistes Activitat
1
de març 15
9167
1
de maig 19
10518
0
de jul. 25
13
2
de juny 24
1099
0
de gen. 22
2373