This question has been flagged
1 Reply
4467 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?


Avatar
Discard
Best Answer

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,

Avatar
Discard
Author

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

Hello, You also can set domain in the action.