'If updating manager of a department, we need to update all the employees
of department hierarchy, and subscribe the new manager.'

@api.multi
def write(self, vals):

    if ('manager_id' in vals):
        manager_id = vals.get('manager_id')
        if manager_id:
            manager = self.env['hr.employee'].browse(manager_id)
            if manager.user_id:
                self.message_subscribe_users(user_ids=manager.user_id.ids)
        employees = self.env['hr.employee']
        for department in self:
            employees = (employees | self.env['hr.employee'].search([('id', '!=', manager_id), ('department_id', '=', department.id), ('parent_id', '=', department.manager_id.id)]))
        employees.write({'parent_id': manager_id})
    return super(Department, self).write(vals)
