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.

1

How to include the partner information in my module?

By
Praveen S
on 7/6/13, 8:00 AM 1,961 views

hi ,

In my module i need to add contact persons such as company as well as person. How the existing person information to be included in my module? Pls provide some examples too.

Thanks, Praveen

Here is my work files . I didn't able create the view for partner

i tried that one but it doesn't give any results. I will give my work files to you.

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'), }

dealer()

dealer_view.xml

<openerp> <data>

<menuitem id="dealer_main_menu" name="Dealer"/>
<record id="dealer_dealer_tree_view" model="ir.ui.view">
    <field name="name">dealer.dealer.tree</field>
    <field name="model">dealer</field>
    <field name="arch" type="xml">
        <tree string="Regions">
            <field name="name"/>
            <field name="region_id"/>
        </tree>
    </field>
</record>
<record id="dealer_dealer_form_view" model="ir.ui.view">
    <field name="name">dealer.dealer.form</field>
    <field name="model">dealer</field>
    <field name="arch" type="xml">
        <form string="dealer">
    <field name="street"/>#inherited from partner module. I need all information from partner table like this
                <field name="name"/>
    <field name="region_id"/>       
       </form>
    </field>
</record>
<record id="dealer_normal_action" model="ir.actions.act_window">
    <field name="name">Dealer</field>
    <field name="res_model">dealer</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
</record>

<menuitem id="section_main_menu" parent="dealer_main_menu" name="dealer Information"/> <menuitem id="dealer_real_menu" parent="section_main_menu" action="dealer_normal_action" name="dealer"/> </data> </openerp>

Hello, CAN you describe what you Want to achieve in your module ? I don't understand your need

Tuxservices, Jeudy Nicolas
on 7/7/13, 6:36 PM

hi Nicolas, i am planning to include a dealer module. So i need to add their contact information in the partner table and other information in my dealer module. So i want to include the contact information in my module and get this partnerid in my table. How to do this?

i need to keep all contact information as like a customer and some additional information in the dealer table. I need the customer contact views and store the contact info in partner table and other info in dealer table . Keep the partner id in dealer table.

Praveen S
on 7/8/13, 4:51 AM
0
Praveen S
On 7/11/13, 2:13 PM

Hi Nicolas, Here is my work files

dealer.py

from openerp.osv import osv,fields

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

dealer_view.xml

<openerp>

<data>

<menuitem id="dealer_main_menu" name="Dealer"/>
<record id="dealer_dealer_tree_view" model="ir.ui.view">
    <field name="name">dealer.dealer.tree</field>
    <field name="model">dealer</field>
    <field name="arch" type="xml">
        <tree string="Regions">
            <field name="dealer_name"/>
            <field name="region_id"/>
        </tree>
    </field>
</record>

<record id="dealer_dealer_form_view" model="ir.ui.view">
    <field name="name">dealer.dealer.form</field>
    <field name="model">dealer</field>

    <field name="arch" type="xml">

        <form string="dealer">
                <field name="name"/>
                <field name="dealer_name"/>
                <field name="region_id"/>
       </form>
    </field>
</record>

<record id="dealer_normal_action" model="ir.actions.act_window">
    <field name="name">Dealer</field>
    <field name="res_model">dealer</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
</record>

<menuitem id="section_main_menu" parent="dealer_main_menu" name="dealer Information"/>

<menuitem id="dealer_real_menu" parent="section_main_menu" action="dealer_normal_action" name="dealer"/>

</data>

</openerp>

0
Flyguy
On 7/9/13, 10:10 AM

And what is the difference between a dealer and a normal partner? Maybe it's enough to add a tag 'Dealer' on some partners. And add some fields if needed. If you need a lot of changes in attributes and functions, you can inherit a new object from partner.

in fact he clearly says: "i need to keep all contact information as like a customer and some additional information in the dealer table. I need the customer contact views and store the contact info in partner table and other info in dealer table . Keep the partner id in dealer table."

Tuxservices, Jeudy Nicolas
on 7/9/13, 10:22 AM
0

Jeudy Nicolas

--Jeudy Nicolas--
1181
| 6 7 8
PELOUSEY, France
--Jeudy Nicolas--

- Linux administrator - Functional guy with OpenERP - Python, html, css, javascript developer OpenERP Ready Partner

Jeudy Nicolas
On 7/8/13, 3:42 PM

hello,

You need to use inherit mecanism (like res.user do with res.partner)

Define your object like this:

class dealer(osv.osv):

    _inherits = {
        'res.partner': 'partner_id',
    }
    _name = "dealer"
    _description = 'Dealer'

Now if you query dealer, you have dealer field + res.partner field. If you query res.partner, you have only partner field.

Check in openobject-server/openerp/addons/base/res/res_users.py to see an example of this.

For the view, you can add a new view on dealer like other object, or you can copy view you like for res.partner for exemple. Just say that you want a view on your new object (with technical group check on administrator):

image description

  • Settings -> technical -> useer interface Views
  • Create

And fill the form like this in your case:

image description

  1. Name of the view
  2. Name of your inherited object if you want all field to be available.
  3. You can use all fields from res.partner and dealer model like:

  4. name, street, email etc ..

i tried that one. But the difficulty faced by me was, how to set up the views for inherited object. Please give some clarification about setting up of views for this inherited object

Praveen S
on 7/9/13, 5:00 AM

I had this explain on my answer, tell me if it's ok for you, and check answered if it's ok :)

Tuxservices, Jeudy Nicolas
on 7/9/13, 9:01 AM

i tried that one but it doesn't give any results. My work files are added to the question pls verify it and give me instruction to how to create such kind of views.

Praveen S
on 7/9/13, 2:46 PM

In my use case I needed entities for vendor and vendor contacts but found inheriting from partner problematic due to access rules. My solution is to create entirely separate entities and give the parent a many2one field for res.user. Now I have entities which will not be interfered with by partner access rules but which can still be associated to partner through res.user. Now it is simple to make custom views which inherit from either if the association exists.

mike
on 7/9/13, 3:32 PM

Hi Nicolas r u noticed my updates. Pls help me if you know it

Praveen S
on 7/10/13, 6:14 AM

Yes I add this to me answer .. your update about view ?

Tuxservices, Jeudy Nicolas
on 7/11/13, 4:13 AM

Nicolas how to create views for my module. When i am tried to include the fields of partner module as like my updated view it will generates an error. how to solve it.

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

Can you put the error message ? I will try to create a small module with a working example. Be careful, I think you have set up 2 times the field name (res.partner already has it). The one of dealer will replace res.partner. I think you should use dealer_name.

Tuxservices, Jeudy Nicolas
on 7/11/13, 11:50 AM

ok i will try that and the error is error - ValidateError Error occurred while validating the field(s) arch: Invalid XML for View Architecture!

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

Ok the view definition is incorrect, can you past it here I will give you the correct syntaxe :)

Tuxservices, Jeudy Nicolas
on 7/11/13, 12:56 PM

The xml code is included with the question. Pls note that and give me correct syntax. i already change my name to dealer_name but the same error occurs when i put the name field in view.

Praveen S
on 7/11/13, 1:38 PM

Hi Praveen, pliz past the entire error message because all you need is written in it. I need the complete traceback to be able to help you.

Tuxservices, Jeudy Nicolas
on 7/11/13, 2:17 PM

Nicolas when i am trying to install that module i will get this error as an alert box ValidateError

Error occurred while validating the field(s) arch: Invalid XML for View Architecture!

no other explanation is there.

Praveen S
on 7/11/13, 3:48 PM
0

Acespritech

--Acespritech--
839
| 3 2 6
India
--Acespritech--

Having 8+ years of OpenERP Experience. We are Specialized in OpenERP/CRM Solutions, software development, Web development, E commerce solutions & other open source solutions.


Skype : acespritech

Email : info@acespritech.com

Acespritech
On 7/8/13, 4:15 AM

Hello !

If I understand correct, you want to display all existing customers list in your form and you want to select any one from existing.
If this is the case then you have to define field in your class like,
'partner_id': fields.many2one('res.partner', 'Customers')

If something else then please specify your requirement in details.

Thanks,
Acespritech Solutions Pvt. Ltd.
www.acespritech.com
Mail: info@acespritech.com
Skype: acespritech
Blog: http://acespritechblog.wordpress.com

I didn't want the existing customer. I am planning to introduce a new entity Dealer. So i need to store their contact information. How its possible with the help of partner module?

Praveen S
on 7/8/13, 5:02 AM

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/6/13, 8:00 AM
Seen: 1961 times
Last updated: 3/16/15, 8:10 AM