Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
10388 Vues

@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
Ignorer
Meilleure réponse

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
Ignorer
Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
1
mars 15
9171
1
mai 19
10529
0
juil. 25
13
2
juin 24
1104
0
janv. 22
2377