This question has been flagged
2 Replies
5107 Views

Say I have a python class from odoo that inherits 'res.partner' to add a number of fields to the model.

To improve overall code clearness I want to separate that file into two pieces. So in my module I will have two python files that both inherit res.partner. However, when I inherit res.partner again I get an error saying that there is a column missing (the first field in the second python file). 

How can I inherit from the same model twice within the same custom module?

Avatar
Discard
Author Best Answer

Already solved my own problem: 

It is possible to inherit the same base model in the same custom module. Just make sure your xml import (If you split those up as well) are in the correct order.

Avatar
Discard
Best Answer

You can inherit the same base model twice or thrice or any number of times, just ensure the class name is different from other, that way inheritance will not be overlapped..

For example

class ResPartner(models.Model):
_inherit = 'res.partner'
...

class ResPartner2(models.Model):
    _inherit = 'res.partner'
...

class ResPartner3(models.Model): _inherit = 'res.partner'
...


Avatar
Discard