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.


How create a custom field selection that depends of ther fields.

James Ford
on 2/21/16, 11:12 AM 520 views

Hello , I'm trying to create a custom fields that depends of other Fields. A custom field selection shows only data of other fields that i select previously.

I created a custom model called x_business.center with two fields called x_partner ( man2one to res.partner ) and x_name (char) as shown in the picture :

Image #1: http://es.zimagez.com/zimage/p1344.php

On the other hand I added a custom field called x_costcenter (many2one to x_business.center) sale.order model as shown in the picture :In Form view sale.order ( sale.order.form ) I added the x_costcenter field as shown in the picture :

Image #2: http://es.zimagez.com/zimage/p2254.php

I want to do is that the field Cost Center depends of Customer, in other words , the customer that i select, the Cost Center field shows only the Cost Centers that Customer , I don't want all cost centers are displayed.

Image #3: http://es.zimagez.com/zimage/p3184.php

Image #4: http://es.zimagez.com/zimage/p4158.php

That is all. I want to thank you for your time and dedication . Thanks I'll be waiting anxiously your advices and proposals. :)


Jusab Sida (jsi)

--Jusab Sida (jsi)--
Tiny ERP Pvt Ltd
| 2 1 5
Gandhinagar, India
--Jusab Sida (jsi)--

Jusab Sida (jsi)
On 2/22/16, 11:29 AM

In sale order formview, Just add domain in you custom field 

<field name="x_costcenter" domain="[('x_partner','=',partner_id)]"/>

Dr Obx
On 2/21/16, 5:01 PM

I'm trying to understand what exactly you wanted to achieve :)

I was thinking how you can do it. In my case I've done something like this but in slightly complicated manner.

Created a few classes then depending on the value in first field second field is loading data from specific table then based on the value from second third is loaded and so on.

but I've had to create also a load of records in each of the classes.

For example if I choose Computer, next field loads data from table computers, then if I choose brand, next field loads data about model of this brand, then size and data about computers/model will be loaded and so on.

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: 2/21/16, 11:12 AM
Seen: 520 times
Last updated: 2/22/16, 3:10 PM