Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
10383 Vistas

@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
Mejor respuesta

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
Mejor respuesta

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
Publicaciones relacionadas Respuestas Vistas Actividad
1
mar 15
9169
1
may 19
10526
0
jul 25
13
2
jun 24
1102
0
ene 22
2376