@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user