From 1acd0b6c5d7ce292f670882f6ff48a2ff9db05f0 Mon Sep 17 00:00:00 2001 From: "Abdelouahab (abla)" Date: Tue, 16 Jan 2024 10:45:19 +0100 Subject: [PATCH] [FIX] hr_attendance: fix checkin/checkout on iOS To reproduce ============ - With hr_attendance installed on ios application - click on small button (green/red) to checkin/checkout - nothing happens Problem ======= the method `signInOut` is failling because `navigator.geolocation` is not defined on iOS Solution ======== check if `navigator.geolocation` is defined before using it opw-3649654 closes odoo/odoo#149518 Signed-off-by: Sofie Gvaladze (sgv) --- .../attendance_menu/attendance_menu.js | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/addons/hr_attendance/static/src/components/attendance_menu/attendance_menu.js b/addons/hr_attendance/static/src/components/attendance_menu/attendance_menu.js index 885637e5d07..0c727b05d7a 100644 --- a/addons/hr_attendance/static/src/components/attendance_menu/attendance_menu.js +++ b/addons/hr_attendance/static/src/components/attendance_menu/attendance_menu.js @@ -52,19 +52,25 @@ export class ActivityMenu extends Component { } async signInOut() { - navigator.geolocation.getCurrentPosition( - async ({coords: {latitude, longitude}}) => { - await this.rpc("/hr_attendance/systray_check_in_out", { - latitude, - longitude - }) - await this.searchReadEmployee() - }, - async err => { - await this.rpc("/hr_attendance/systray_check_in_out") - await this.searchReadEmployee() - } - ) + if(navigator.geolocation){ + navigator.geolocation.getCurrentPosition( + async ({coords: {latitude, longitude}}) => { + await this.rpc("/hr_attendance/systray_check_in_out", { + latitude, + longitude + }) + await this.searchReadEmployee() + }, + async err => { + await this.rpc("/hr_attendance/systray_check_in_out") + await this.searchReadEmployee() + } + ) + } + else{ + await this.rpc("/hr_attendance/systray_check_in_out") + await this.searchReadEmployee() + } } }