Odoo Help


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.


Creating A Dropdown Menu With Customer Names

Alex Gallien
on 7/21/14, 4:53 PM 448 views

I am looking to add a customer field to the products screen. In my business problem, each product is assigned to one customer specifically. I tried copying the code from the Sales Order form, but that didn't work out - I got a label for my field, but no menu to select from. This is the line I added:

In my .py:

    'x_cust_name': fields.many2one('res.partner', 'Customer', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, required=True, change_default=True, select=True, track_visibility='always'),

In my .xml:

          <field name="x_cust_name" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>


This hasn't worked so far. Is there a way to get a nice dropdown menu of customers to appear in the products form? Thanks!

Nhomar Hernandez
On 7/22/14, 1:12 AM


In my .py:

_id for convention, not x_* due to this name is reserved for other porpose.

    'customer_id': fields.many2one('res.partner', 'Customer'),

In my .xml:

          <field name="customer_id"/>

But I think you are reinventing the wheel.

It is done here:


It is a little more complicated than what you want to do but the data model is done already.


Thanks! That was super helpful. I overcomplicated things as usual. I read that using x_* in custom modules was a best practice, in case of updates later. Is that not the case? What is x_* reserved for?

Alex Gallien
on 7/22/14, 1:31 PM

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)


Asked: 7/21/14, 4:53 PM
Seen: 448 times
Last updated: 3/16/15, 8:10 AM