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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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
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.
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