diff --git a/yuthon_hr_employee/data/employee_recruitment_time_data.xml b/yuthon_hr_employee/data/employee_recruitment_time_data.xml
index 049f68a72..16bf99538 100644
--- a/yuthon_hr_employee/data/employee_recruitment_time_data.xml
+++ b/yuthon_hr_employee/data/employee_recruitment_time_data.xml
@@ -14,5 +14,18 @@
-1
+
+ 定时任务:自动生成转正审批
+
+ code
+ model.regularization_task()
+
+
+ 1
+ days
+
+ -1
+
+
diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py
index 98a702654..0e7ae35dd 100644
--- a/yuthon_hr_employee/models/yuthon_hr_employee.py
+++ b/yuthon_hr_employee/models/yuthon_hr_employee.py
@@ -189,6 +189,7 @@ class YuthonHrEmployee(models.Model):
string='薪资计算年金人员'
)
salary_year = fields.Integer(compute='_compute_salary_year', store=True)
+ is_create = fields.Boolean(string='是否已创建转正流程审批')
last_year_salary = fields.Float(string="年金基数")
converted = fields.Float(string="折算实际系数")
conversion_factor = fields.Float(string="上年有效计算")
@@ -911,3 +912,38 @@ class YuthonHrEmployee(models.Model):
'number_of_days': total_days,
})
+ def regularization_task(self):
+ today = fields.Date.today()
+ target_date = today + timedelta(days=15)
+ eligible_employees = self.search([
+ ('is_create', '=', False),
+ ('contract_id.is_probation', '=', True),
+ ('contract_id.end_date', '=', target_date),
+ ('contract_id', '!=', False)
+ ])
+ if not eligible_employees:
+ return
+
+ for employee in eligible_employees:
+ contract_structure_type = employee.contract_id.structure_type_id
+ approval_name = f"转正申请表-{employee.name}"
+ self.env['yuthon.regularization.approval'].create({
+ 'name': approval_name,
+ 'users_id': employee.user_id.id,
+ 'create_uid': employee.user_id.id,
+ 'structure_type_id': contract_structure_type.id,
+ 'structure_type_id1': contract_structure_type.id,
+ 'is_adjust': False,
+ })
+ menu_id = self.env['ir.ui.menu'].search([('name', '=', '转正申请表')])
+ url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=yuthon.regularization.approval&view_type=list&menu_id={menu_id.id}'
+ self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa',
+ user_id=employee.wecom_userid,
+ title="转正申请",
+ description=f"""您好!近期即将开展您的转正流程,现就转正申请事宜温馨提醒如下,确保流程顺利推进:
+ 待办工作流:已为您生成「转正申请审批单」待办任务,可登录 OA 查看处理;
+ 提交时限:请于试用期截止前 1 周(即{employee.contract_id.end_date.year}年{employee.contract_id.end_date.month}月{employee.contract_id.end_date.day}日)完成审批单提交,逾期可能影响转正进度;
+ 材料准备:需同步上传《转正申请书》(可向人事部门索取,企业微信联系人事对接人)。""",
+ url=url, btntxt="详细信息")
+
+ employee.write({'is_create': True})
diff --git a/yuthon_hr_employee_approval/models/yuthon_regularization_approval.py b/yuthon_hr_employee_approval/models/yuthon_regularization_approval.py
index ac91b1c06..ce9a710b8 100644
--- a/yuthon_hr_employee_approval/models/yuthon_regularization_approval.py
+++ b/yuthon_hr_employee_approval/models/yuthon_regularization_approval.py
@@ -57,16 +57,17 @@ class YuthonRegularizationPrepareApproval(models.Model):
main_version = version_str.split('.')[0]
new_main_version = int(main_version) + 1
new_version = f"V{new_main_version}.0"
- original_contract = rec.employee_ids.contract_id
+ original_contract = rec.users_id.employee_ids.contract_id
original_contract.write({
- 'state': 'close',
+ 'state': 'cancel',
})
new_contract_vals = {
'structure_type_id': rec.structure_type_id1.id,
- 'new_version': new_version,
+ 'version': new_version,
+ 'state': 'open',
}
new_contract = original_contract.with_context(skip_contract_code_check=True).copy(new_contract_vals)
- rec.employee_id.write({
+ rec.users_id.employee_ids.write({
'contract_id': new_contract.id,
})