diff --git a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py index bf26e75da..06250dab3 100644 --- a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py +++ b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py @@ -97,12 +97,23 @@ class HrAttendanceDetail(models.Model): @api.model def create(self, vals): record = super(HrAttendanceDetail, self).create(vals) - if record.employee_id.name not in ['龙春球', 'Administrator']: + if record.employee_id.name not in ['Administrator']: resource_user_ids = record.employee_id.resource_calendar_id.resource_user_ids.ids is_resource_user = True if record.employee_id.id in resource_user_ids else False - if record.employee_id and record.checkin_time and record.source == 'iot' and not is_resource_user: - employee_id = record.employee_id - checkin_datetime = record.checkin_time + employee_id = record.employee_id + checkin_datetime = record.checkin_time + last_record = self.search([ + ('employee_id', '=', employee_id.id), + ('source', '=', 'iot'), + ('checkin_time', '<', checkin_datetime) + ], order='checkin_time desc', limit=1) + # 如果上一条记录存在,并且时间差 < 60秒 → 不发提醒 + skip_notify = False + if last_record: + time_diff = checkin_datetime - last_record.checkin_time + if time_diff.total_seconds() < 60: + skip_notify = True # 小于1分钟,跳过提醒 + if record.employee_id and record.checkin_time and record.source == 'iot' and not is_resource_user and not skip_notify: current_data = record.checkin_time.date() + timedelta(hours=8) day_start = checkin_datetime.replace(hour=0, minute=0, second=0, microsecond=0) day_end = checkin_datetime.replace(hour=23, minute=59, second=59, microsecond=99) @@ -121,13 +132,16 @@ class HrAttendanceDetail(models.Model): resource_user_ids = employee_id.resource_calendar_id.resource_user_ids.ids is_resource_user = True if employee_id.id in resource_user_ids else False # 哺乳人员 - suckling_employees = employee_id.resource_calendar_id.breastfeeding_holiday_ids.mapped('employee_id') + suckling_employees = employee_id.resource_calendar_id.breastfeeding_holiday_ids.mapped( + 'employee_id') + def get_all_upper_depts(dept): """递归获取部门及其所有上级部门的ID列表""" dept_ids = [dept.id] if dept.parent_id: dept_ids.extend(get_all_upper_depts(dept.parent_id)) return dept_ids + all_dept_ids = get_all_upper_depts(employee_id.department_id) if not is_resource_user: diff --git a/yuthon_hr_attendance/models/vacation_overtime_active.py b/yuthon_hr_attendance/models/vacation_overtime_active.py index 5da818683..47acc26d4 100644 --- a/yuthon_hr_attendance/models/vacation_overtime_active.py +++ b/yuthon_hr_attendance/models/vacation_overtime_active.py @@ -184,7 +184,7 @@ class VacationOvertimeActive(models.Model): ('carry_forward_date', '=', self.carry_forward_date), '&', ('carryover_type', '=', 'leave'), - ('carry_forward_date', '>', last_day), + ('over_line_id.start_time', '>', last_day), ] view_id = self.env.ref('yuthon_hr_attendance.view_overtime_carryover_tree1').id return {