Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to inherit the same model twice the same module

By
Pieter Paulussen
on 11/9/16, 6:22 AM 121 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?

0
Pieter Paulussen
On 11/9/16, 7:06 AM

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.

0

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 11/10/16, 1:19 AM

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'
...


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/9/16, 6:22 AM
Seen: 121 times
Last updated: 11/10/16, 1:19 AM