From 53cad6f9f7ba7c258e22eeff5112c2b4ccbc4aaf Mon Sep 17 00:00:00 2001 From: Renaud Thiry Date: Tue, 15 Nov 2022 15:46:17 +0000 Subject: [PATCH] [FIX] calendar: show dialog when sync unconfigured ## Issue Currently if an administrator installs one of the sync modules but does not set any credentials. If the user tries to sync their calendar they are met with an error. ## Fix Make sure they get a clear dialog explaining why they cannot sync. task - 3056311 X-original-commit: 6ec6a3764c5e5460aa8a1cdfa228740606fdfe13 Part-of: odoo/odoo#106517 --- .../google_calendar_controller.js | 20 ++++++++++--------- .../microsoft_calendar_controller.js | 20 ++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/addons/google_calendar/static/src/views/google_calendar/google_calendar_controller.js b/addons/google_calendar/static/src/views/google_calendar/google_calendar_controller.js index 601a1c2aed3..407a6b25315 100644 --- a/addons/google_calendar/static/src/views/google_calendar/google_calendar_controller.js +++ b/addons/google_calendar/static/src/views/google_calendar/google_calendar_controller.js @@ -19,15 +19,17 @@ patch(AttendeeCalendarController.prototype, "google_calendar_google_calendar_con [[this.user.userId]], ); const syncResult = await this.model.syncGoogleCalendar(); - if (syncResult.status === "need_auth") { - this.configureCalendarProviderSync("google"); - } else if (syncResult.status === "need_config_from_admin") { - if (Number.isInteger(syncResult.action)) { - this.dialog.add(ConfirmationDialog, { - title: this.env._t("Configuration"), - body: this.env._t("The Google Synchronization needs to be configured before you can use it, do you want to do it now?"), - confirm: this.actionService.doAction.bind(this.actionService, syncResult.action), - }); + if (["need_auth", "need_config_from_admin"].includes(syncResult.status)) { + if (this.isSystemUser) { + if (syncResult.status === "need_auth") { + this.configureCalendarProviderSync("google"); + } else if (syncResult.status === "need_config_from_admin") { + this.dialog.add(ConfirmationDialog, { + title: this.env._t("Configuration"), + body: this.env._t("The Google Synchronization needs to be configured before you can use it, do you want to do it now?"), + confirm: this.actionService.doAction.bind(this.actionService, syncResult.action), + }); + } } else { this.dialog.add(AlertDialog, { title: this.env._t("Configuration"), diff --git a/addons/microsoft_calendar/static/src/views/microsoft_calendar/microsoft_calendar_controller.js b/addons/microsoft_calendar/static/src/views/microsoft_calendar/microsoft_calendar_controller.js index 59dd7494946..39bd5e77e1a 100644 --- a/addons/microsoft_calendar/static/src/views/microsoft_calendar/microsoft_calendar_controller.js +++ b/addons/microsoft_calendar/static/src/views/microsoft_calendar/microsoft_calendar_controller.js @@ -19,15 +19,17 @@ patch(AttendeeCalendarController.prototype, "microsoft_calendar_microsoft_calend [[this.user.userId]], ); const syncResult = await this.model.syncMicrosoftCalendar(); - if (syncResult.status === "need_auth") { - this.configureCalendarProviderSync("microsoft"); - } else if (syncResult.status === "need_config_from_admin") { - if (Number.isInteger(syncResult.action)) { - this.dialog.add(ConfirmationDialog, { - title: this.env._t("Configuration"), - body: this.env._t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"), - confirm: this.actionService.doAction.bind(this.actionService, syncResult.action), - }); + if (["need_auth", "need_config_from_admin"].includes(syncResult.status)) { + if (this.isSystemUser) { + if (syncResult.status === "need_auth") { + this.configureCalendarProviderSync("microsoft"); + } else if (syncResult.status === "need_config_from_admin") { + this.dialog.add(ConfirmationDialog, { + title: this.env._t("Configuration"), + body: this.env._t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"), + confirm: this.actionService.doAction.bind(this.actionService, syncResult.action), + }); + } } else { this.dialog.add(AlertDialog, { title: this.env._t("Configuration"),