Odoo Help

Welcome!

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.

0

Domain : employee dropdown of particular department and job title

By
Fongoh Tayong
on 2/3/16, 4:56 AM 359 views

Greetings.


working on a repair module and have mechanic as field 

mechanic_id = fields.Many2one('hr.employee', string="Mechanic's In Charge")

In my view, i want to limit the employees in the dropdown to be employees only in "garage" department and job type "mechanic". 

This is my code

 <field name="mechanic_id" required="1" 
domain="('job_id.name', '=', 'Mechanic'),
('department_id.name', '=', 'Garage')" />

But it tells me name is not an attribute. 


Sorry if i have funny code, but what am i doing wrong?


2

Jignesh Mehta

--Jignesh Mehta--
2087
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 2/3/16, 5:26 AM

Hello Fongoh,


Try this


<field name="mechanic_id" required="1"attrs="{'domain' : {'job_id': [('name', '=', 'Mechanic')], 'department_id': [('name', '=', 'Garage')]}}" />


Hope it will works for you.

Thanks,

Thanks Kingnesh, it worked very well. In case i want to set action and context of same filters, please, how do i achieve that?

Fongoh Tayong
on 2/3/16, 6:19 AM

Hello, You also can set domain in the action.

Jignesh Mehta
on 2/3/16, 6:35 AM

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)

Stats

Asked: 2/3/16, 4:56 AM
Seen: 359 times
Last updated: 2/3/16, 5:58 AM