Odoo Help


How to add custom tab with option to select people from a list (res.partner)

on 11/13/14, 3:18 AM 2,322 views

Hi everybody

I'm in the progress of adding a new tab under sales > Customers > New.

I've added the code for the model under sale/res_partner.py like this:

columns = {
        'sale_order_count': fields.function(_sale_order_count, string='# of Sales Order', type='integer'),
        'sale_order_ids': fields.one2many('sale.order','partner_id','Sales Order'),
        'x_testpersoon': fields.boolean('Testpersoon'),
        'x_geslacht': fields.selection([('M', 'Man / Male / Homme'), ('F', 'Vrouw / Female / Femme')], 'Geslacht'),
        'x_geboortedatum': fields.date('Geboortedatum'),
        'x_opleiding': fields.selection([('Middelbaar', 'Middelbaar / Secondary school / Études secondaires'),
        ('Bachelor', 'Bachelor / Bachelor / Bachelier'), 
        ('Master', 'Master / Master / Master'), 
        ('Universiteit', 'Universiteit / University / Université')], 'Opleiding'),
        'x_beroep': fields.char('Beroep', size=64),
        'x_taal': fields.selection([('NL', 'Nederlands / Dutch / Néerlandais'),
        ('EN', 'Engels / English / Anglais'), 
        ('FR', 'Frans / French / Français')], 'Taal'),
        'session_ids': fields.one2many('res.partner', 'id', string="Gebruikers"),

I've added the code for a new view under /sale/res_partner_view.xml like this:

<page string="Externe personen">
                <field name="session_ids">
                        <tree string="Gebruikers">
                                 <field name="name"/>
                                 <field name="phone"/>

I now get this view:

Which is exactly what I want. But when I now click on "Add an Item" it opens up a menu to make a new customer, like this:

I want a selection showing ALL customers / partners in our system and the ability to check the ones I want, like this:

And then the chosen people should show up in my previous form(view).
What I believe to have wrong is the session_ids in the model. 
My question is how can I show the dialog which will show me ALL customers/partners in a dialog where I can let the user choose from?

NOTE: I know the problem is I need a many2many but this is not allowed because I would need a many2many from the same model?

With kind regards



| 8 8 8

My Odoo blog: http://www.odoo.yenthevg.com/

My Twitter: https://twitter.com/Yenthe666

On 11/13/14, 5:02 AM

The problem was just as I thought in the line 'session_ids': fields.one2many('res.partner', 'id', string="Gebruikers") of the models.
I needed a many2many here which referenced an external table to 'save' the records.

The final result should be like this:

'session_ids': fields.many2many('res.partner', 'custom_model_multi_customers_to_customer', 'session_id', 'partner_id', string="Sessions"),


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

1 follower(s)


Asked: 11/13/14, 3:18 AM
Seen: 2322 times
Last updated: 3/16/15, 8:10 AM