Skip to Content
Menu
This question has been flagged
1 Reply
4618 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.

Related Posts Replies Views Activity
1
May 24
1306
1
Nov 22
3297
2
Jul 22
2097
2
May 18
8875
2
Mar 18
4088