コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
2774 ビュー

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



アバター
破棄
著作者 最善の回答

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()


アバター
破棄
最善の回答

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

アバター
破棄
著作者

Thanks but there is no change.

関連投稿 返信 ビュー 活動
1
3月 15
5788
0
3月 15
5494
0
5月 21
3520
2
4月 20
15625
4
3月 19
16195