Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
2873 มุมมอง

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.

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 15
5864
0
มี.ค. 15
5570
0
พ.ค. 21
3650
Scheduled Actions Not Running แก้ไขแล้ว
2
เม.ย. 20
15728
4
มี.ค. 19
16279