From 94b690216a32dc6b42acc8b0c974952d451e0547 Mon Sep 17 00:00:00 2001 From: zhouzhou <123@qq.com> Date: Tue, 12 Nov 2024 18:41:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_hr_employee/models/yuthon_hr_employee.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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):