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

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

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

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
Ignorer
Auteur

Thanks but there is no change.

Publications associées Réponses Vues Activité
1
mars 15
5869
0
mars 15
5576
0
mai 21
3674
2
avr. 20
15748
4
mars 19
16306