From 42d916e27b230cd072df1c43c93d1ab0d2f1d3d1 Mon Sep 17 00:00:00 2001 From: Samir Ladoui Date: Wed, 12 Feb 2025 15:18:09 +0100 Subject: [PATCH] [FIX] odex_mobile: get back restrictions single sign in --- .../controllers/rest_api_v2/attendance.py | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/odex25_mobile/odex_mobile/controllers/rest_api_v2/attendance.py b/odex25_mobile/odex_mobile/controllers/rest_api_v2/attendance.py index 8b4355316..59666f77f 100644 --- a/odex25_mobile/odex_mobile/controllers/rest_api_v2/attendance.py +++ b/odex25_mobile/odex_mobile/controllers/rest_api_v2/attendance.py @@ -202,38 +202,38 @@ class AttendanceController(http.Controller): order='name desc', limit=1) system_checkout = json.loads(body.get('system_checkout')) if 'system_checkout' in body else False - # if not rec or rec and rec.action != body.get('action'): - attendance = http.request.env['attendance.attendance'].create({ - 'employee_id':employee.id, - 'action':body.get('action'), - 'action_type':"system_checkout" if body.get('action') == 'sign_out' and system_checkout == True else 'application', - 'name': fields.datetime.now(), - # 'device_id':body.get('device_id'), - 'zone':zone.zone if zone else "%s,%s" % (body.get('longitude'), body.get('latitude')), - 'longitude': body.get('longitude'), - 'latitude':body.get('latitude'), - }) - if attendance: - if body.get('action') == 'sign_out' and system_checkout == True: - msg = (_("System Force Sign out Due to Change Location Permission ")) - subject = (_("System Force Sign out")) - self.send_msg(employee, msg, subject) + if not rec or rec and rec.action != body.get('action'): + attendance = http.request.env['attendance.attendance'].create({ + 'employee_id':employee.id, + 'action':body.get('action'), + 'action_type':"system_checkout" if body.get('action') == 'sign_out' and system_checkout == True else 'application', + 'name': fields.datetime.now(), + # 'device_id':body.get('device_id'), + 'zone':zone.zone if zone else "%s,%s" % (body.get('longitude'), body.get('latitude')), + 'longitude': body.get('longitude'), + 'latitude':body.get('latitude'), + }) + if attendance: + if body.get('action') == 'sign_out' and system_checkout == True: + msg = (_("System Force Sign out Due to Change Location Permission ")) + subject = (_("System Force Sign out")) + self.send_msg(employee, msg, subject) - date = attendance.name.time() - data = { - "id": attendance.id, - "action": attendance.action, - "attendance_status": attendance.action, - "time": str(date), - "zone": attendance.zone, - "longitude": attendance.longitude, - "latitude": attendance.latitude, - "range": zone.allowed_range if zone else False, - } - msg = (_("Check Out successfully")) if body.get('action') == 'sign_out' else (_("Check in successfully")) - # else: - # msg = (_("Check Fail Due To Duplication")) - # data = {} + date = attendance.name.time() + data = { + "id": attendance.id, + "action": attendance.action, + "attendance_status": attendance.action, + "time": str(date), + "zone": attendance.zone, + "longitude": attendance.longitude, + "latitude": attendance.latitude, + "range": zone.allowed_range if zone else False, + } + msg = (_("Check Out successfully")) if body.get('action') == 'sign_out' else (_("Check in successfully")) + else: + msg = (_("Check Fail Due To Duplication")) + data = {} # Reset last_active_time when the employee signed out if body.get('action') == 'sign_out': employee.last_active_time = False