This question has been flagged
1 Reply
4931 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

Avatar
Discard

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?

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
Best Answer

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.

 

Avatar
Discard