diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index ab4d9879d..37dc77370 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -180,8 +180,19 @@ class YuthonHrEmployee(models.Model): def _compute_social_insurance_time(self): for record in self: record.social_insurance_time = record.cumulative_work_month - record.interrupt_work_month - if record.social_insurance_time < 0: - record.social_insurance_time = 0 + total_months = int(record.social_insurance_time) + if total_months <= 0: + record.social_insurance_time = "0个月" + years = total_months // 12 + months = total_months % 12 + if years > 0: + result_str = f"{years}年" + if months > 0: + result_str += f"{months}个月" + else: + result_str = f"{months}个月" + record.social_insurance_time = result_str + @api.depends('identification_id') # 只依赖身份证号码 def _compute_info(self):