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

I inherited a model and put in a method for a scheduled action with some helper functions. I'm getting this error when i run it from the front end why?

NameError: name 'do_something_else' is not defined

I have something like this..


classProducTemplate(models.Model):    
​_inherit = 'product.template'​

​def action_do_something(self):
​do_something_else()
​@staticmethod
​def do_something_else():
​pass



Avatar
Descartar
Autor Mejor respuesta

I omitted "self"

class ProducTemplate(models.Model):
_inherit = 'product.template'

@staticmethod
def do_something_else():
pass

def action_do_something(self):
self.do_something_else()


Avatar
Descartar
Mejor respuesta

Hi,

The definition do_something_else needs to exist before you start to reference it.

class ProducTemplate(models.Model):
_inherit = 'product.template'

@staticmethod
def do_something_else():
pass

def action_do_something(self):
do_something_else()

Regards

Avatar
Descartar
Autor

Thanks but there is no change.

Publicaciones relacionadas Respuestas Vistas Actividad
1
mar 15
5762
0
mar 15
5481
0
may 21
3516
2
abr 20
15607
4
mar 19
16186