diff --git a/yuthon_hr_attendance/models/hr_attendance.py b/yuthon_hr_attendance/models/hr_attendance.py index e38533bc6..79e73b59a 100644 --- a/yuthon_hr_attendance/models/hr_attendance.py +++ b/yuthon_hr_attendance/models/hr_attendance.py @@ -1238,23 +1238,21 @@ class HrAttendance(models.Model): record.shift_name = '行政班次' def labor_update(self): - start_date = fields.Date.to_date('2025-05-01') - end_date = fields.Date.to_date('2025-05-05') - # 搜索符合条件的考勤记录 - attendance_records = self.search([ - ('current_data', '>=', start_date), - ('current_data', '<=', end_date), - ('shift_id', '=', False), - ]) - if attendance_records: - for record in attendance_records: - record.write({ - 'is_no_card': False, - 'is_early_card': False, - 'is_late_card': False, - 'is_abnormal': False, - 'is_approval': True, - }) + start_date = fields.Date.to_date('2025-09-01') + end_date = fields.Date.to_date('2025-09-23') + + attendance_records = self.env['hr.attendance'].search( + [('current_data', '>=', start_date), + ('current_data', '<=', end_date)], + order='current_data, employee_id, id' # 按日期、员工、ID排序,确保顺序稳定 + ) + processed = set() + for record in attendance_records: + key = (record.employee_id.id, record.current_data) + if key not in processed: + processed.add(key) # 第一次出现,保留 + else: + record.unlink() class card_remind_form(models.Model): _name = 'card.remind.form' diff --git a/yuthon_salary/wizard/salary_compute_wizard.py b/yuthon_salary/wizard/salary_compute_wizard.py index bfa135f35..5b59b3387 100644 --- a/yuthon_salary/wizard/salary_compute_wizard.py +++ b/yuthon_salary/wizard/salary_compute_wizard.py @@ -183,6 +183,7 @@ class SalaryComputeWizard(models.Model): internship_ids = self.env['hr.payslip'].search([ ('is_push', '=', False), ('company_id', '=', self.company_id.id), + ('employee_id.name', '=', '林嘉宜'), ('date_from', '<=', end_date), ('date_to', '>=', start_date), ]) @@ -223,6 +224,7 @@ class SalaryComputeWizard(models.Model): internship_start = max(original_start_date, contract_start_date) internship_end = min(original_end_date, contract_end_date) + last_days = self._process_shift_days(internship_start - relativedelta(months=1),internship_start - relativedelta(days=1)) # 判断该员工是否需补发上月工资 if contract_start_date.year == internship_start.year and contract_start_date.month == (internship_start - relativedelta(months=1)).month and contract_start_date.day > 15: last_internship_days = self._process_shift_days(contract_start_date, internship_start - relativedelta(days=1)) @@ -267,23 +269,23 @@ class SalaryComputeWizard(models.Model): if field_name == 'performance_bonuses': if work_days != internship_days: - result = (base_80 * internship_days + line.total * work_days * last_internship_days * RATIO_80) / days + result = (base_80 * internship_days + line.total * work_days) / days else: - result = base_80 * (internship_days + last_internship_days) / days + result = base_80 * internship_days / days + base_80 * last_internship_days / last_days result = math.ceil(result * 100) / 100 elif field_name == 'full_attendance_award': - result = line.total * last_internship_days / days + result = line.total * last_internship_days / last_days elif field_name in ['commuting_allowance', 'seniority_salary']: if work_days != internship_days: - result = math.ceil(( line.total * internship_days + line.total * work_days + line.total * last_internship_days) / days * 100) / 100 + result = math.ceil(( line.total * internship_days + line.total * work_days) / days * 100) / 100 else: - result = math.ceil(line.total * (internship_days + last_internship_days) / days * 100) / 100 + result = math.ceil((line.total * internship_days / days + line.total * last_internship_days / last_days) * 100) / 100 elif field_name in ['rank_salary', 'base_salary']: if work_days != internship_days: result = ( base_80 * internship_days + line.total * work_days + line.total * last_internship_days * RATIO_80) / days else: - result = base_80 * (internship_days + last_internship_days) / days + result = base_80 * internship_days / days + base_80 * last_internship_days / last_days result = math.ceil(result * 100) / 100