Odoo Help

0

Populating Dropdown menu based on Partner Category

By
John Pia Jr
on 5/23/14, 10:31 AM 1,491 views

Is it possible to populate a dropdown list with a set of partners that have a specific tag associated with them? I need this desperately 

thanks

Edit: I am referring to a certain object is a form view

Where do you need to populate this dropdown list? Somewhere on the website? In the search bar of list views? In the form view of a certain object?

Fabrice Henrion (fhe)
on 5/23/14, 6:02 PM

Hi fabrice.

I am referring to a certain object is a form view

On May 23, 2014 6:02 PM, "Fabrice Henrion" <fhe@openerp.my.openerp.com> wrote:

Where do you need to populate this dropdown list? Somewhere on the website? In the search bar of list views? In the form view of a certain object?

__
Fabrice Henrion
Director Americas

OpenERP Inc.
51 Federal Street, Suite 401
San Francisco, CA 94107
Tel: +1 (650) 307-6736
http://www.openerp.com

Sent by OpenERP Inc. using OpenERP. Access your messages and documents in Odoo
John Pia Jr
on 5/23/14, 6:10 PM
2
Ben Olsen
On 5/23/14, 6:12 PM

I know this is possible, but I'm still fairly new at this too, so I can only give you a vague pointer. However, if you look at the file:

addons/purchase/purchase_view.xml

Around line 191 there's this field:

<field name="partner_id" on_change="onchange_partner_id(partner_id)" context="{'search_default_supplier':1,'default_supplier':1,'default_customer':0}" domain="[('supplier','=',True)]"/>

When you go to create a new purchase order, this is the "Supplier" dropdown, where you get to select which partner is the supplier for that product. Notice that this field passes a context, which limits the values of the select box. (As a side note, I think the domain controls when this field is active. This same page on the sales quotation side has domain="[('customer','=',True)]" instead.)

So if you wanted to override this particular field in a custom module, you'd do something like this:

    <record id="my_tagged_partners" model="ir.ui.view">
        <field name="name">my.view.form</field>
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.purchase_order_form"/>
        <field name="arch" type="xml">
            <field name="partner_id" position="replace">
               <field name="partner_id" on_change="onchange_partner_id(partner_id)" context="{'search_default_supplier':1,'default_supplier':1,'default_customer':0,'search_tag':'favorite'}" domain="[('supplier','=',True)]"/>
            </field>
        </field>
    </record>

And that would (in theory) look for partners that had the "favorite" tag. Unfortunately I haven't tried this and don't know if search_tag is actually what you want. Hopefully this gets you in the right direction, though.

 

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.

Register

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

4 follower(s)

Stats

Asked: 5/23/14, 10:31 AM
Seen: 1491 times
Last updated: 3/16/15, 8:10 AM