Skip to Content
Menu
This question has been flagged

In my company when creating a helpdesk ticket, in the field "customer" you have to put a customer that is registered in the contacts module as a company. I need to create a related field in odoo studio that allows me to select a contact from all the contacts that the company has registered. I have tried to do it through the domain configuration option but it does not work.

This is the domain I have registered but it does not give me the desired results.

[["parent_id.name","=","partner_id"]]



But if I edit it by putting the name of a company registered in my Odoo, then if it brings me the contacts of that company, something like that:

[["parent_id.name","=","Cliente Modelo, C.A."]].







Avatar
Discard
Best Answer

Hi, 


There seems to be a bug but also a workaround. 

To create a dynamic domain, you need to 

1) You need to have 2 many-to-one fields. One for "Cliente" and one for "Contacto del Cliente". Both are using the "Contact" model.

2) Create your domain as you did but than you change it (in the black window below the fields) and you replace the double quotes with single quotes: 

[["parent_id","=","partner_id"]] shall be [['parent_id','=','x_studio_many2one_field_contact']]

=> note: x_studio_many2one_field_contact is the name of the field "Cliente"

3) Now, activate the debug mode and click on "View" (left - top) and on "XML". Now you need to locate your field in the right file. Once you located it, modify it from 

[['parent_id','=','x_studio_many2one_field_contact']] to domain="[['parent_id','=',x_studio_many2one_field_contact]]"(remove the single quotes only for x_studio_many2one_field_contact)


The domain should work now, but you will get an error if you try to modify the domain using the wizard. To modify the domain later on, you need to do it in the XML-view. 


Best regards, 


Avatar
Discard
Related Posts Replies Views Activity
1
Jan 23
2703
1
Oct 23
2370
0
Mar 23
1227
0
Feb 25
18
0
Mar 24
1455