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

I want to call same function from another class-object. I try this but doesn't work.Any help please.

class ClassA(models.Model):
    _name = 'class.a'
        def action_button(self):
              ......
        }

class ClassB(models.Model):
    _name = 'class.b'
    def call_func_b(self):
        self.env["class.b"].action_button()

 <button name="call_func_b" type="object" string="Create Action b"/>


class ClassC(models.Model):
    _name = 'class.c'
    def call_func_c(self):
        self.env["class.c"].action_button()

 <button name="call_func_c" type="object" string="Create Action c"/>

頭像
捨棄
最佳答案

You are almost there except you are calling the method with wrong object.

Try this:

self.env["class.a"].action_button()

If you want to call the method of classA, then you should use the object name of classA (class.a)

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
3
2月 25
3304
0
5月 24
46
1
4月 24
3228
4
9月 23
4706
2
9月 23
6919