Skip to Content
Menu
This question has been flagged
2 Replies
3090 Views

Hello,


odoo has a good support for different kinds of inheritance, but what is the reason about it's implementation? 

I really don't know how can I call 'super' in a class that inherits, in Python's terms, from Model, and if this class has a "_inherit = 'my.parent.model'", the super actually calls the class of 'my.parent.model' and not Model. How does this work out?

I went some time through Model class code and its parents and saw some code that maybe manipulate the class inheritance, but is not clear to me.

Thanks

Avatar
Discard
Best Answer
simple example for inheritance :

class User(models.Model): _inherit = 'res.users' is_commercial = fields.Boolean(string= 'is Commercial') // i added this field to res.users table @api.multi def write(self, values): super(User, self).write() // here i called supper write method
for partner in self.partner_id: partner.is_commercial = self.is_commercial

here is official odoo documentation docs:

https://www.odoo.com/documentation/14.0/howtos/backend.html#inheritance

Avatar
Discard
Author Best Answer

Thank you Ibrahim, but that is not what i'd asked for. 

Still,  I think I've managed to get how odoo manages inheritance of Python class implicitly using _inherit. Apparently, is by changing the __bases__ property of the Model classes.

This is at '_build_model' of models.py.

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 21
2085
0
Aug 24
1065
1
Jul 24
1821
1
Mar 22
4613
1
Jun 21
3017