From f650da355323e1696967290e2b7ee4a14c761e0e Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Mon, 7 Apr 2025 10:05:24 +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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index 7bdb7b7a9..3e0dc5820 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -171,11 +171,6 @@ class YuthonHrEmployee(models.Model): @api.depends('social_base_on', 'social_base_off') def _compute_insurance_bases(self): current_month = datetime.now().month - self.medical_insurance_base = self.pension_insurance_base = self.work_injury_insurance_base = self.housing_fund_base = 0 - if 1 <= current_month <= 6: - base = self.social_base_on - else: - base = self.social_base_off insurance_names = { '基本医疗保险费': 'medical_insurance_base', '基本养老保险费': 'pension_insurance_base', @@ -184,6 +179,13 @@ class YuthonHrEmployee(models.Model): } insurance_records = self.env['yuthon.payroll.insurances'].search([('name', 'in', list(insurance_names.keys()))]) for record in self: + # 初始化所有保险基数为 0 + for field_name in insurance_names.values(): + setattr(record, field_name, 0) + if 1 <= current_month <= 6: + base = record.social_base_on + else: + base = record.social_base_off for insurance in insurance_records: field_name = insurance_names[insurance.name] if base > insurance.employee_base_ceiling: @@ -193,7 +195,6 @@ class YuthonHrEmployee(models.Model): else: setattr(record, field_name, base) - @api.onchange('job_id') def _onchange_job_id(self): if self.job_id: