From 7b3a7bbf420e80e6fa2fef4deb2867ec562548d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Thu, 3 Jul 2025 15:11:45 +0800 Subject: [PATCH] 1 --- .../controllers/applet_attendance.py | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/yuthon_hr_attendance/controllers/applet_attendance.py b/yuthon_hr_attendance/controllers/applet_attendance.py index c29c11e14..3479514f8 100644 --- a/yuthon_hr_attendance/controllers/applet_attendance.py +++ b/yuthon_hr_attendance/controllers/applet_attendance.py @@ -47,18 +47,16 @@ class AppletAttendance(Controller): current_data = fields.Date.today() user_id = request.env(user=SUPERUSER_ID)["res.users"].search([('id', '=', int(kw['user_id']))]) employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_id.name)]) - address_id = request.env(user=SUPERUSER_ID)["applet.address"].search( - [('address_name', '=', employee_id.company_id.name)]) + address_id = request.env(user=SUPERUSER_ID)["applet.address"].search([('address_name', '=', employee_id.company_id.name)]) self_address = self.get_address_from_coords(kw['att_latitude'], kw['att_longitude']) _logger.info(f"打卡经度{kw['att_longitude']}打卡纬度{kw['att_latitude']}__________") _logger.info(f"人员{employee_id.name}地址{self_address['formatted_address']}__________") card_rice = address_id.card_rice * 0.001 # 打卡范围 - attendance_id = request.env(user=SUPERUSER_ID)["hr.attendance"].search( - [('employee_id', '=', employee_id.id), ('current_data', '=', current_data)]) - check_in = attendance_id.check_in + timedelta(hours=8) - check_out = attendance_id.check_out + timedelta(hours=8) + attendance_id = request.env(user=SUPERUSER_ID)["hr.attendance"].search([('employee_id', '=', employee_id.id), ('current_data', '=', current_data)]) + check_in = attendance_id.check_in + timedelta(hours=8) if attendance_id.check_in else '' + check_out = attendance_id.check_out + timedelta(hours=8) if attendance_id.check_out else '' check_in_start = attendance_id.shift_id.template_id.check_in_start check_out_end = attendance_id.shift_id.template_id.check_out_end start_minute = int((check_in_start - int(check_in_start)) * 60) @@ -78,21 +76,17 @@ class AppletAttendance(Controller): state_result = '缺卡' check_in_str = check_in.strftime('%H:%M:%S') if check_in else ' ' check_out_str = check_out.strftime('%H:%M:%S') if check_out else ' ' - check_in_html = f'

{check_in_str}

' if check_in_status in ['迟到', '早退', - '缺卡'] else f'

{check_in_str}

' - check_out_html = f'

{check_out_str}

' if check_out_status in ['迟到', '早退', - '缺卡'] else f'

{check_out_str}

' + check_in_html = f'

{check_in_str}

' if check_in_status in ['迟到', '早退', '缺卡'] else f'

{check_in_str}

' + check_out_html = f'

{check_out_str}

' if check_out_status in ['迟到', '早退', '缺卡'] else f'

{check_out_str}

' if not self.is_within_radius_geopy(kw['att_latitude'], kw['att_longitude'], address_id.latitude, address_id.longitude, card_rice): message = "超出范围,不允许打卡" state = "no" - state_result = "超出范围" _logger.info("-------触发超出范围,不允许打卡---------") else: state = 'yes' message = 'ok' - state_result = '' data = { - 'location': '%s' % address_id.address_name, + 'location': self_address['formatted_address'], 'user_id': user_id.id, 'class': f"{attendance_id.shift_name}{start_time_str}-{end_time_str}", 'state_result': state_result,