From 64186386629ae6062f3cbb6ce47d25cfeb650c74 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Thu, 28 Mar 2024 13:14:44 +0100 Subject: [PATCH] [FIX] point_of_sale: show the loading PoS data error Before this commit, if there was an error, the PoS stays on the loading page which was confusing for the user. owp-3834647 closes odoo/odoo#159710 Signed-off-by: Adrien Guilliams (adgu) --- addons/point_of_sale/static/src/app/main.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/point_of_sale/static/src/app/main.js b/addons/point_of_sale/static/src/app/main.js index 426d0cea521..6153c1cc5fb 100644 --- a/addons/point_of_sale/static/src/app/main.js +++ b/addons/point_of_sale/static/src/app/main.js @@ -9,6 +9,7 @@ import { hasTouch } from "@web/core/browser/feature_detection"; import { localization } from "@web/core/l10n/localization"; import { makeEnv, startServices } from "@web/env"; import { session } from "@web/session"; +import { RPCError } from "@web/core/network/rpc_service"; const loader = reactive({ isShown: true }); whenReady(() => { @@ -28,6 +29,19 @@ whenReady(() => { // setup environment const env = makeEnv(); await startServices(env); + + // handle loading PoS error + if (env.services.pos instanceof Error) { + let message = _t("An error occurred while loading the Point of Sale: \n"); + if (env.services.pos instanceof RPCError) { + message += env.services.pos.data.message; + } else { + message += env.services.pos.message; + } + window.alert(message); + window.location = "/web#action=point_of_sale.action_client_pos_menu"; + } + // start application await whenReady(); const app = new App(Chrome, {