Can anyone explain model inheritance and method override concept? I have module A with function/method X being extended using super in module B. then I have module C overriding function X from module A. It seems that extended function from module B not executed, is there any explanation about this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
Hello Bayu Arasyi,
• Make sure you have inherited the model using “_inherit” and while Overriding the method you have called super method in the both the modules B & C.
• As with the use of “Super” method you can override the method and the code done before can be extended.
• Now based on your requirement if you want to extend your code first , then return super method at last otherwise vice-versa.
Find Code in Comment.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
class A(self):
_name = “x.y”
def X(self):
<your code>
class B(self):
_inherit = “x.y”
def X(self):
res = super(B, self).x()
<your extended code>
return res
class C(self):
_inherit = “x.y”
def X(self):
<your extended code>
return super(C,self).m()
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
0
يناير 17
|
4715 | ||
can't override a function
تم الحل
|
|
1
يونيو 16
|
4749 | |
|
0
يونيو 25
|
761 | ||
|
1
أغسطس 23
|
3899 | ||
|
0
أبريل 23
|
2977 |
I know there are 3 types of inheritance. But I was faced with several problems.
It would be more helpful if you give a sample code or example so that we can explain you with your example.