diff --git a/yuthon_hr_employee_approval/models/yuthon_onboard_approval.py b/yuthon_hr_employee_approval/models/yuthon_onboard_approval.py index 3b7b800e3..052bf9781 100644 --- a/yuthon_hr_employee_approval/models/yuthon_onboard_approval.py +++ b/yuthon_hr_employee_approval/models/yuthon_onboard_approval.py @@ -218,6 +218,13 @@ class YuthonOnboardApproval(models.Model): employee_id.write({'is_membership': True}) # employee_id.send_wecom_employee() employee_id.create_user() + # 根据公司名匹配 res.groups 中 department_ids 包含该公司名的组,把新用户加进去 + if employee_id.user_id and self.company_id and self.company_id.name: + matched_groups = self.env['res.groups'].sudo().search([ + ('department_ids.name', 'ilike', self.company_id.name) + ]) + if matched_groups: + matched_groups.sudo().write({'users': [(4, employee_id.user_id.id)]}) iots = self.env['attendance.iot'].sudo().search([('company_id', '=', self.company_id.id)]) for iot in iots: iot.action_init_device()