Odoo Help


How to define domain with active_id for many2one field?

Atchuthan - Technical Consultant, Sodexis Inc
on 10/31/13, 4:37 AM 5,972 views

Hi friendz,

I have a many2one field 'default_profile_id' in object 'CIM'

'default_profile_id': fields.many2one('cim.object','Default Profile', domain="[('cim_id','=',id)]"),

in the view file,

<field name="default_profile_id" widget="selection" />

By doing this, I thought I would get the list of profile that are for customer profile like a SELECTION field, but the DOMAIN restriction is not working.

My Requirement is that:

I want to show payment profile available for the current Customer Profile in SELECTION Format

<field name="default_profile_id" widget="selection" domain="[('cim_id','=',active_id)]" /> But showing error as active_id is not available

Thanks & Regards,



Anil R. Kesariya

--Anil R. Kesariya--
| 7 6 8
Rajkot, India
--Anil R. Kesariya--

Odoo Techno Functional Expert

* Engaged with odoo since May - 2012.

* Customise existing module or develop new module base on customer requirement.

* Played key developer role in many past and running projects.

* Expert in requirement gathering of business and transforming requirement into odoo platform.

* Major expertise in core modules, database, report development and theme development.

* Integration expert.

Linkedin  : https://in.linkedin.com/in/anil-kesariya-97b20a66

Anil R. Kesariya
On 10/31/13, 5:46 AM

Hello atchuthan,

If you want that records from profile those are belongs to cim.object. Than make sure in cim.object there must be one2many field with the "name" cim_id and the object of that field would be your current class object in which you have added this default_profile_id.

Now you just need to give domain in xml only

<field name="default_profile_id" widget="selection" domain="[('cim_id','=',active_id)]"/> Now your xml domain will work it will give you the records the profile which has the active_id.

If still it not work it means the domain is not work with widget you have used. so you need to override the search method. this the last option What you say?

regarding active_id I tried but error mentioned that active_id not defined.

My work needs me to remove "Create and Edit" in the many2one field. Domain works in py file as i defined like this:

domain="[('cim_id','=',id)]" inside the fields.many2one definition

Atchuthan - Technical Consultant, Sodexis Inc
on 10/31/13, 6:17 AM

Is it possible to create selection field using functions such that current ID records are only shown??

Atchuthan - Technical Consultant, Sodexis Inc
on 10/31/13, 6:18 AM

Yes it is possible.

Anil R. Kesariya
on 11/21/13, 9:36 AM

thanks, but can you provide me a sample code for this.

Atchuthan - Technical Consultant, Sodexis Inc
on 11/22/13, 5:08 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/31/13, 4:37 AM
Seen: 5972 times
Last updated: 3/31/15, 5:36 PM