添加功能
This commit is contained in:
@@ -720,6 +720,7 @@ class YuthonVacationReports(models.Model):
|
||||
probation_days = 0 # 试用期天数
|
||||
regular_days = 0 # 转正天数
|
||||
actual_attendance = 0 # 实到天数 = 应到天数 - 请假总天数 - 异常天数
|
||||
leave_total_days = 0 # 累计请假天数
|
||||
is_retired = rec.employee_id.user_state in ('leave', 'withdraw')
|
||||
if rec.employee_id and rec.vacation_date and not is_retired:
|
||||
year = rec.vacation_date.year
|
||||
@@ -740,15 +741,35 @@ class YuthonVacationReports(models.Model):
|
||||
])
|
||||
|
||||
if attendances:
|
||||
# 1. 过滤有效考勤:仅排除休息/异常,保留请假记录
|
||||
valid_attendances = [
|
||||
att for att in attendances
|
||||
if (att.check_in or att.check_out)
|
||||
and att.shift_name != '休息'
|
||||
and (not att.workflow_id or att.workflow_id.workflow_id.name != '请假')
|
||||
and not att.is_abnormal
|
||||
]
|
||||
leave_hours = 0
|
||||
leave_days = 0
|
||||
processed_leave_codes = set() # 记录已处理的请假单code,避免重复扣减
|
||||
|
||||
for att in attendances:
|
||||
if att.workflow_id and att.workflow_id.workflow_id.name == '请假':
|
||||
leave_record = self.env[att.workflow_id.res_model].sudo().browse(att.workflow_id.res_id)
|
||||
if leave_record.code and leave_record.code in processed_leave_codes:
|
||||
continue
|
||||
|
||||
if leave_record.days:
|
||||
leave_days += leave_record.days
|
||||
if leave_record.code:
|
||||
processed_leave_codes.add(leave_record.code)
|
||||
|
||||
total_leave_days = leave_days
|
||||
leave_total_days += leave_days
|
||||
if valid_attendances:
|
||||
actual_attendance += 1
|
||||
daily_actual = max(1 - total_leave_days, 0)
|
||||
actual_attendance += daily_actual
|
||||
|
||||
rec.actual_attendance = max(actual_attendance, 0)
|
||||
|
||||
for att in attendances:
|
||||
if att.is_late_card:
|
||||
|
||||
Reference in New Issue
Block a user