跳至內容
選單
此問題已被標幟
2 回覆
2905 瀏覽次數

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
5870
0
3月 15
5578
0
5月 21
3677
2
4月 20
15759
4
3月 19
16306