跳至内容
菜单
此问题已终结
2 回复
2740 查看

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
5753
0
3月 15
5458
0
5月 21
3505
2
4月 20
15595
4
3月 19
16175