Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
10262 Visualizzazioni

@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
Abbandona
Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
mar 15
9072
1
mag 19
10433
0
lug 25
13
2
giu 24
1020
0
gen 22
2296