pengyuthon wechat
This commit is contained in:
@@ -49,19 +49,20 @@ class CardApprovals(models.Model):
|
||||
record.name = f"{record.users_id.name}补卡"
|
||||
|
||||
def confirm_approval(self):
|
||||
calendar_attendances = self.env['resource.calendar'].search([])
|
||||
min_hour_from = min(att.hour_from for att in calendar_attendances)
|
||||
if min_hour_from == 8:
|
||||
min_hour_from = 9
|
||||
max_hour_to = max(att.hour_to for att in calendar_attendances)
|
||||
min_hour_from = self.users_id.employee_id.resource_id.calendar_id.attendance_ids[0].hour_from
|
||||
min_hour = int(min_hour_from)
|
||||
min_minute = int(min_hour_from * 10 % min_hour_from)
|
||||
max_hour_to = self.users_id.employee_id.resource_id.calendar_id.attendance_ids[-1].hour_to
|
||||
max_hour = int(max_hour_to)
|
||||
max_minute = int(max_hour_to * 10 % max_hour_to)
|
||||
for rec in self:
|
||||
if rec.replacement_time == 'work':
|
||||
rec.attendance_id.check_in = rec.attendance_id.check_in.replace(hour=min_hour_from)
|
||||
rec.attendance_id.check_in = rec.attendance_id.check_in.replace(hour=min_hour, minute=min_minute) - timedelta(hours=8)
|
||||
if rec.replacement_time == 'quitting':
|
||||
rec.attendance_id.check_out = rec.attendance_id.check_in.replace(hour=max_hour_to)
|
||||
rec.attendance_id.check_out = rec.attendance_id.check_in.replace(hour=max_hour, minute=max_minute) - timedelta(hours=8)
|
||||
if rec.replacement_time == 'all':
|
||||
rec.attendance_id.check_in = rec.attendance_id.check_in.replace(hour=min_hour_from)
|
||||
rec.attendance_id.check_out = rec.attendance_id.check_in.replace(hour=max_hour_to)
|
||||
rec.attendance_id.check_in = rec.attendance_id.check_in.replace(hour=min_hour, minute=min_minute) - timedelta(hours=8)
|
||||
rec.attendance_id.check_out = rec.attendance_id.check_in.replace(hour=max_hour, minute=max_minute) - timedelta(hours=8)
|
||||
rec.attendance_id.is_approval = True
|
||||
|
||||
# @api.onchange('is_issues')
|
||||
|
||||
@@ -59,23 +59,23 @@ class HrAttendance(models.Model):
|
||||
record.is_no_card = False
|
||||
record.is_late_card = False
|
||||
record.is_early_card = False
|
||||
calendar_attendances = self.env['resource.calendar.attendance'].search([])
|
||||
min_hour_from = min(att.hour_from for att in calendar_attendances)
|
||||
if min_hour_from == 8:
|
||||
min_hour_from = 9
|
||||
max_hour_to = max(att.hour_to for att in calendar_attendances)
|
||||
# 迟到 晚打卡 大于上班时间
|
||||
min_hour_from = record.employee_id.resource_id.calendar_id.attendance_ids[0].hour_from
|
||||
min_hour = int(min_hour_from)
|
||||
min_minute = int(min_hour_from * 10 % min_hour_from)
|
||||
|
||||
if record.check_in:
|
||||
check_in = record.check_in + timedelta(hours=8)
|
||||
will_datetime_start = check_in.replace(hour=int(min_hour_from),
|
||||
minute=int((min_hour_from % 1) * 100), second=0)
|
||||
will_datetime_start = check_in.replace(hour=min_hour, minute=min_minute)
|
||||
record.is_late_card = check_in > will_datetime_start
|
||||
else:
|
||||
record.is_no_card = True
|
||||
# 早退,小于下班时间
|
||||
|
||||
max_hour_to = record.employee_id.resource_id.calendar_id.attendance_ids[-1].hour_to
|
||||
max_hour = int(max_hour_to)
|
||||
max_minute = int(max_hour_to * 10 % max_hour_to)
|
||||
if record.check_out:
|
||||
check_out = record.check_out + timedelta(hours=8)
|
||||
will_datetime_end = check_out.replace(hour=int(max_hour_to), minute=int((min_hour_from % 1) * 100), second=0)
|
||||
will_datetime_end = check_out.replace(hour=max_hour, minute=max_minute)
|
||||
record.is_early_card = will_datetime_end > check_out
|
||||
else:
|
||||
record.is_no_card = True
|
||||
|
||||
Reference in New Issue
Block a user