Skip to Content
Menu
This question has been flagged
1 Reply
2368 Views

department_id = fields.Many2one('hr.department', string='Dział', required=True, track_visibility='onchange', store=True)

employee_id = fields.Many2many('hr.employee', 'department_id', index=True)


 @api.depends('department_id')

@api.onchange('department_id')

def _compute_employees(self):

emp_data = self.env['hr.employee'].browse([('department_id','in',self.department_id.id)])

for department in self:

department.employee_id = emp_data    


Don't work...



Avatar
Discard
Best Answer

Hai Michal,

    Just make a small change in your onchange function.


    @api.onchange('department_ids')
    def get_employee(self):
        if self.department_ids: 
            self.employee_ids = self.env['hr.employee'].search([('department_id','=',self.department_ids.id)])

It will work for you.

Thanks

Avatar
Discard
Related Posts Replies Views Activity
0
Nov 22
755
0
Nov 22
1464
0
Jun 22
760
2
Mar 20
3236
1
Apr 24
860