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 add custom tab with option to select people from a list (res.partner)

By
Yenthe
on 11/13/14, 3:18 AM 1,823 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"/>
                        </tree>
                </field>
   </page>

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
Yenthe

0

Yenthe

--Yenthe--
6706
| 7 7 8
Turnhout, Belgium
--Yenthe--

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

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

Yenthe
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"),

 

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/13/14, 3:18 AM
Seen: 1823 times
Last updated: 3/16/15, 8:10 AM