تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
7612 أدوات العرض

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
فبراير 25
2813
0
مايو 24
46
1
أبريل 24
2959
4
سبتمبر 23
4398
2
سبتمبر 23
6660