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 create view for inherited objects?

By
Praveen S
on 7/11/13, 1:58 AM 2,218 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?

dealer.py

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

PARVATHY VIJAYAN P
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
1
nazarii
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.

0

Grover Menacho

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

Systems Engineer + MBA

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

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

0 follower(s)

Stats

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