Odoo Help


How to create view for inherited objects?

Praveen S
on 7/11/13, 1:58 AM 3,030 views

hi, I am facing issues related to creating views in inherited objects. I am planning to add a dealer module. Here is my python file. How to create views for it?


from openerp.osv import osv,fields

class dealer(osv.Model):
    _name = 'dealer'
    _inherit = { 'res.partner': 'partner_id', } 
    _columns = { 'name': fields.char('Name', size = 30,required=True), 
                   'region_id': fields.many2one('region.region', 'Region'), }

How to include the partner table info in my view. Pls help me with some examples.

can you explain your needs clearly

on 7/11/13, 3:41 AM

Hi Parvathy Vijayan,

I am planning to create a new module dealer. I want to treat this dealer as a partner.All his contact info must be saved in partner and other info will be saved in dealer. That's why i am inheriting the partner module. But the problem is that how to include the fields associated with partner in my view. Please give an explanation with some examples. Its similar to res_user but i can't understand the view associated with that module.

Praveen S
on 7/11/13, 11:29 AM



| 5 4 7
On 7/11/13, 6:44 PM

Why don't you modify existing res.partner class adding new checkbox 'dealer' instead of creating new model? Here is a good explanation of xml inheritance.


Grover Menacho

--Grover Menacho--
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Odoo Developer

Grover Menacho
On 7/11/13, 8:13 PM

Let me explain you something.

As I see your code you are creating a new object inheriting the res.partner. What you are doing is that you are creating a new class with new record with ANY relation with res.partner.

If you want to create a new place to see the dealers just add a new field on your class.

Like is a company. Is it a dealer?

Then you can create another menu calling the same res_partner_view but with domain filtering only dealers.

hello Grover i need to add some additional info in the dealer table. so i wish to store all the contact info in partner table and other info in dealer table. how it is possible? its similar to res_user but i didn't understand its view structure.

Praveen S
on 7/12/13, 5:01 AM

There are many ways to do it.

GH Mediacloud, Grover Menacho
on 7/12/13, 12:17 PM

First you can create new fields on the same res.partner. Inherit but without a new name. You can create a new boolean field as i told you "Is it a dealer?" and other additional fields. Then you can add a new tab page below with attrs invisible when is_it_dealer=False. So if it's a dealer then it's going to have additional info

GH Mediacloud, Grover Menacho
on 7/12/13, 12:20 PM

Another way is creating a new module dealer. But with a many2one field with res.partner. So you can associate a partner to your new module dealer. The new module doesn't need an inheritance of re.partner. You just need a many2one field that links them.

GH Mediacloud, Grover Menacho
on 7/12/13, 12:21 PM

Grover my problem is how to use that existing view. Many2one is not suitable for me. i need to use all fields in res_partner. i can't create views for inherited fields. how its possible?

Praveen S
on 7/13/13, 1:45 AM

Well. Maybe if you can give more details about your new view. As I understood is that you are creating a new partner but with more data as a dealer. If that's the case you only have to inherit res.partner and add dealer fields. It's not going to affect the other partners. As I told you you can add a boolean field to check if it's dealer. and depending that field dealer fields are going to be available. That's the way that I see a solution for this. Well that's what I understood.

GH Mediacloud, Grover Menacho
on 7/13/13, 2:47 PM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 7/11/13, 1:58 AM
Seen: 3030 times
Last updated: 3/16/15, 8:10 AM