From d11bf24dea44e93efe0cd5acac14070b9f9d23a8 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Thu, 27 Apr 2023 06:58:36 +0000 Subject: [PATCH] [REF] pos*, web: make pos service start asynchronously *: point_of_sale, pos_hr, pos_restaurant Previously, the pos service started synchronously, but doing anything meaningful with it needed to be done after it was "ready", meaning it had loaded and processed the data. The reason for this is that we need to start the services before we mount the chrome, but in the pos we want to show the loader immediately while the data is loading. This means that any service that depends on the pos service in a meaningful manner has to be written in a convoluted way, where it starts as a dummy service and then overwrites itself in the env when it's actually ready. This commit allows to write services that depend on the pos service more naturally, by making the pos service properly asynchronous, meaning its dependents will only be loaded once it's actually ready. To work around the loader issue, the loader is mounted as a separate owl appplication with not services, this application is shown over the chrome and when the chrome mounts, it hides the loader and destroys the loader application after the fade-out transition. closes odoo/odoo#119908 Signed-off-by: Joseph Caburnay (jcb) --- .../l10n_fr_pos_cert/static/src/js/Chrome.js | 23 ++-- .../src/app/customer_display_service.js | 55 +++----- .../static/src/app/debug/debug_service.js | 11 +- .../static/src/app/loader/loader.js | 21 ++++ .../static/src/app/loader/loader.scss | 101 +++++++++++++++ .../static/src/app/loader/loader.xml | 14 +++ .../point_of_sale/static/src/app/pos_store.js | 65 ++++++++-- addons/point_of_sale/static/src/entry/main.js | 17 ++- .../static/src/img/bc-arrow-big.png | Bin 315 -> 0 bytes addons/point_of_sale/static/src/js/Chrome.js | 89 ++----------- addons/point_of_sale/static/src/js/models.js | 2 + addons/point_of_sale/static/src/scss/pos.scss | 117 ------------------ .../point_of_sale/static/src/xml/Chrome.xml | 43 +++---- .../static/tests/unit/pos_app_tests.js | 9 +- addons/pos_hr/static/src/app/pos_store.js | 6 + addons/pos_hr/static/src/js/Chrome.js | 6 - .../static/src/app/pos_store.js | 13 +- addons/pos_restaurant/static/src/js/Chrome.js | 20 --- .../static/src/js/Screens/TicketScreen.js | 6 +- addons/web/static/src/start.js | 3 +- 20 files changed, 283 insertions(+), 338 deletions(-) create mode 100644 addons/point_of_sale/static/src/app/loader/loader.js create mode 100644 addons/point_of_sale/static/src/app/loader/loader.scss create mode 100644 addons/point_of_sale/static/src/app/loader/loader.xml delete mode 100644 addons/point_of_sale/static/src/img/bc-arrow-big.png delete mode 100644 addons/pos_restaurant/static/src/js/Chrome.js diff --git a/addons/l10n_fr_pos_cert/static/src/js/Chrome.js b/addons/l10n_fr_pos_cert/static/src/js/Chrome.js index e281108858b..10a37002fcd 100644 --- a/addons/l10n_fr_pos_cert/static/src/js/Chrome.js +++ b/addons/l10n_fr_pos_cert/static/src/js/Chrome.js @@ -3,18 +3,21 @@ import { Chrome } from "@point_of_sale/js/Chrome"; import { patch } from "@web/core/utils/patch"; import { ClosePosPopup } from "@point_of_sale/js/Popups/ClosePosPopup"; +import { onMounted } from "@odoo/owl"; patch(Chrome.prototype, "l10n_fr_pos_cert.Chrome", { - async start() { - await this._super(...arguments); - if (this.env.pos.is_french_country() && this.env.pos.pos_session.start_at) { - const now = Date.now(); - const limitDate = new Date(this.env.pos.pos_session.start_at); - limitDate.setDate(limitDate.getDate() + 1); - if (limitDate.getTime() < now) { - const info = await this.env.pos.getClosePosInfo(); - this.popup.add(ClosePosPopup, { info }); + setup() { + this._super(...arguments); + onMounted(async () => { + if (this.env.pos.is_french_country() && this.env.pos.pos_session.start_at) { + const now = Date.now(); + const limitDate = new Date(this.env.pos.pos_session.start_at); + limitDate.setDate(limitDate.getDate() + 1); + if (limitDate.getTime() < now) { + const info = await this.env.pos.getClosePosInfo(); + this.popup.add(ClosePosPopup, { info }); + } } - } + }); }, }); diff --git a/addons/point_of_sale/static/src/app/customer_display_service.js b/addons/point_of_sale/static/src/app/customer_display_service.js index 27ae7a08f89..3bef83b4521 100644 --- a/addons/point_of_sale/static/src/app/customer_display_service.js +++ b/addons/point_of_sale/static/src/app/customer_display_service.js @@ -104,46 +104,23 @@ export const customerDisplayService = { start(env, deps) { const { globalState } = deps.pos; - // Dummy service, does nothing until the globalState is ready, then the methods get replaced - const service = { - connect() {}, - }; + const { + iface_customer_facing_display: enabled, + iface_customer_facing_display_via_proxy: proxy, + } = globalState.config; + if (!enabled) { + return; + } - globalState.ready.then(() => { - const { - iface_customer_facing_display: enabled, - iface_customer_facing_display_local: local, - iface_customer_facing_display_via_proxy: proxy, - } = globalState.config; - if (!enabled) { - return; - } - - let display; - if (local) { - display = new LocalDisplay(globalState); - } else if (proxy) { - display = new RemoteDisplay( - globalState, - pick(deps, ...RemoteDisplay.serviceDependencies) - ); - } else { - // FIXME POSREF can this ever happen? - return; - } - // FIXME POSREF this is very inelegant. There are a lot of places that get more complicated - // because we want to mount the chrome before the globalState is loaded. Maybe we should - // just make the loading screen its own thing that doesn't depend on anything, instead - // of having it be a part of the chrome and having to propagate complexity everywhere. - env.services.customer_display = display; - // Register an effect to update the display automatically when anything it renders changes - effect( - batched((display) => display.update()), - [display] - ); - }); - - return service; + const display = proxy + ? new RemoteDisplay(globalState, pick(deps, ...RemoteDisplay.serviceDependencies)) + : new LocalDisplay(globalState); + // Register an effect to update the display automatically when anything it renders changes + effect( + batched((display) => display.update()), + [display] + ); + return display; }, }; diff --git a/addons/point_of_sale/static/src/app/debug/debug_service.js b/addons/point_of_sale/static/src/app/debug/debug_service.js index 1035c35644e..0a4d005d0f3 100644 --- a/addons/point_of_sale/static/src/app/debug/debug_service.js +++ b/addons/point_of_sale/static/src/app/debug/debug_service.js @@ -6,17 +6,14 @@ import { DebugWidget } from "./debug_widget"; import { withComputedProperties } from "@point_of_sale/utils"; const debugService = { - dependencies: ["pos"], /** * @param {{ debug: string }} env - * @param {object} deps - * @param {import("@point_of_sale/app/pos_store").PosStore} deps.pos */ - start(env, { pos }) { + start(env) { const internalState = reactive({ widgetOpen: true }); - const state = withComputedProperties(reactive({}), [internalState, pos], { - showWidget(internalState, pos) { - return env.debug && pos.uiState === "READY" && internalState.widgetOpen; + const state = withComputedProperties(reactive({}), [internalState], { + showWidget(internalState) { + return env.debug && internalState.widgetOpen; }, }); registry.category("main_components").add("DebugWidget", { diff --git a/addons/point_of_sale/static/src/app/loader/loader.js b/addons/point_of_sale/static/src/app/loader/loader.js new file mode 100644 index 00000000000..e3900a1c8a8 --- /dev/null +++ b/addons/point_of_sale/static/src/app/loader/loader.js @@ -0,0 +1,21 @@ +/** @odoo-module */ + +import { Component, useEffect } from "@odoo/owl"; + +export class Loader extends Component { + static template = "point_of_sale.Loader"; + static props = { loader: { type: Object, shape: { isShown: Boolean } } }; + setup() { + useEffect( + (isShown) => { + if (!isShown) { + // Destroy the loader app after it has faded out + setTimeout(() => { + this.__owl__.app.destroy(); + }, 1000); + } + }, + () => [this.props.loader.isShown] + ); + } +} diff --git a/addons/point_of_sale/static/src/app/loader/loader.scss b/addons/point_of_sale/static/src/app/loader/loader.scss new file mode 100644 index 00000000000..68f327ee320 --- /dev/null +++ b/addons/point_of_sale/static/src/app/loader/loader.scss @@ -0,0 +1,101 @@ +.pos-loader { + background-color: #222; + position: absolute; + left: 0px; + top: 0px; + width: 100%; + height: 100%; + z-index: 100001; // 1 more than the debug widget... + text-align: center; + font-family: Lato; + color: $gray-700; + transition: opacity 0.8s; + + .loader-feedback { + width: 400px; + height: 160px; + margin: -60px -200px; + position: absolute; + left: 50%; + top: 50%; + text-align: center; + } + + h1 { + font-weight: 300; + } + + .button { + display: inline-block; + margin: 25px auto; + line-height: 42px; + padding: 0px 16px; + font-size: 20px; + font-weight: 300; + border: solid 1px; + border-radius: 5px; + cursor: pointer; + + :active { + color: #222; + background: $gray-700; + } + } +} + +// loader animation +.lds-ellipsis { + display: inline-block; + position: relative; + width: 80px; + height: 60px; +} +.lds-ellipsis div { + position: absolute; + top: 33px; + width: 13px; + height: 13px; + border-radius: 50%; + background: #fff; + animation-timing-function: cubic-bezier(0, 1, 1, 0); +} +.lds-ellipsis div:nth-child(1) { + left: 8px; + animation: lds-ellipsis1 0.6s infinite; +} +.lds-ellipsis div:nth-child(2) { + left: 8px; + animation: lds-ellipsis2 0.6s infinite; +} +.lds-ellipsis div:nth-child(3) { + left: 32px; + animation: lds-ellipsis2 0.6s infinite; +} +.lds-ellipsis div:nth-child(4) { + left: 56px; + animation: lds-ellipsis3 0.6s infinite; +} +@keyframes lds-ellipsis1 { + 0% { + transform: scale(0); + } + 100% { + transform: scale(1); + } +} +@keyframes lds-ellipsis3 { + 0% { + transform: scale(1); + } + 100% { + transform: scale(0); + } +} +@keyframes lds-ellipsis2 { + 0% { + transform: translate(0, 0); + } + 100% { + transform: translate(24px, 0); + } +} diff --git a/addons/point_of_sale/static/src/app/loader/loader.xml b/addons/point_of_sale/static/src/app/loader/loader.xml new file mode 100644 index 00000000000..19b1e51a3b3 --- /dev/null +++ b/addons/point_of_sale/static/src/app/loader/loader.xml @@ -0,0 +1,14 @@ + + +
+
+ +
+ + +

Connecting to devices

+
+
+
+
+
diff --git a/addons/point_of_sale/static/src/app/pos_store.js b/addons/point_of_sale/static/src/app/pos_store.js index 748d3429631..739eb120e61 100644 --- a/addons/point_of_sale/static/src/app/pos_store.js +++ b/addons/point_of_sale/static/src/app/pos_store.js @@ -11,8 +11,6 @@ import { CashOpeningPopup } from "@point_of_sale/js/Popups/CashOpeningPopup"; import { sprintf } from "@web/core/utils/strings"; export class PosStore extends Reactive { - /** @type {'LOADING' | 'READY' | 'CLOSING'} */ - uiState = "LOADING"; hasBigScrollBars = false; loadingSkipButtonIsShown = false; mainScreen = { name: null, component: null }; @@ -27,10 +25,10 @@ export class PosStore extends Reactive { ]; constructor() { super(); - this.setup(...arguments); + this.ready = this.setup(...arguments).then(() => this); } // use setup instead of constructor because setup can be patched. - setup(env, { popup, orm, number_buffer, hardware_proxy, barcode_reader }) { + async setup(env, { popup, orm, number_buffer, hardware_proxy, barcode_reader }) { this.orm = orm; this.popup = popup; this.numberBuffer = number_buffer; @@ -40,6 +38,13 @@ export class PosStore extends Reactive { // FIXME POSREF: the hardwareProxy needs the pos and the pos needs the hardwareProxy. Maybe // the hardware proxy should just be part of the pos service? this.hardwareProxy.pos = this.globalState; + await this.globalState.load_server_data(); + if (this.globalState.config.use_proxy) { + await this.connectToProxy(); + } + this.closeOtherTabs(); + this.preloadImages(); + this.showScreen("ProductScreen"); } showScreen(name, props) { @@ -126,9 +131,6 @@ export class PosStore extends Reactive { body: reason, }); if (confirmed) { - // FIXME POSREF setting the location prevents the next render, the loading screen never shows - this.globalState.uiState = "CLOSING"; - this.globalState.loadingSkipButtonIsShown = false; window.location = "/web#action=point_of_sale.action_client_pos_menu"; } } @@ -209,12 +211,57 @@ export class PosStore extends Reactive { this.globalState.pos_session.state == "opening_control" ); } + + preloadImages() { + for (const product of this.globalState.db.get_product_by_category(0)) { + const image = new Image(); + image.src = `/web/image?model=product.product&field=image_128&id=${product.id}&unique=${product.write_date}`; + } + for (const category of Object.values(this.globalState.db.category_by_id)) { + if (category.id == 0) { + continue; + } + const image = new Image(); + image.src = `/web/image?model=pos.category&field=image_128&id=${category.id}&unique=${category.write_date}`; + } + const image = new Image(); + image.src = "/point_of_sale/static/src/img/backspace.png"; + } + + /** + * Close other tabs that contain the same pos session. + */ + closeOtherTabs() { + // FIXME POSREF use the bus? + localStorage["message"] = ""; + localStorage["message"] = JSON.stringify({ + message: "close_tabs", + session: this.globalState.pos_session.id, + }); + + window.addEventListener( + "storage", + (event) => { + if (event.key === "message" && event.newValue) { + const msg = JSON.parse(event.newValue); + if ( + msg.message === "close_tabs" && + msg.session == this.globalState.pos_session.id + ) { + console.info("POS / Session opened in another window. EXITING POS"); + this.closePos(); + } + } + }, + false + ); + } } export const posService = { dependencies: PosStore.serviceDependencies, - start(env, deps) { - return new PosStore(env, deps); + async start(env, deps) { + return new PosStore(env, deps).ready; }, }; diff --git a/addons/point_of_sale/static/src/entry/main.js b/addons/point_of_sale/static/src/entry/main.js index 512214219bc..bd59f3fdb3e 100644 --- a/addons/point_of_sale/static/src/entry/main.js +++ b/addons/point_of_sale/static/src/entry/main.js @@ -2,9 +2,16 @@ import { startWebClient } from "@web/start"; import { Chrome } from "@point_of_sale/js/Chrome"; +import { Loader } from "@point_of_sale/app/loader/loader"; +import { templates } from "@web/core/assets"; +import { mount, reactive, whenReady } from "@odoo/owl"; +import { _t } from "@web/core/l10n/translation"; -// FIXME POSREF no we shouldn't but if we did nothing should react, if it does it shouldn't be loaded -// For consistency's sake, we should trigger"WEB_CLIENT_READY" on the bus when PosApp is mounted -// But we can't since mail and some other poll react on that cue, and we don't want those services started -// FIXME POSREF stop using startWebclient: this is not a web client. -startWebClient(Chrome); +const loader = reactive({ isShown: true }); +whenReady(() => { + // Show loader as soon as the page is ready, do not wait for services to be started + // as some services load data over RPC and this is why we want to show a loader. + mount(Loader, document.body, { templates, translateFn: _t, props: { loader } }); +}); +// FIXME POSREF stop using startWebclient?: this is not a web client. +startWebClient(Chrome, { disableLoader: () => (loader.isShown = false) }); diff --git a/addons/point_of_sale/static/src/img/bc-arrow-big.png b/addons/point_of_sale/static/src/img/bc-arrow-big.png deleted file mode 100644 index f845fe6837d05cd3549d3873024e4074fbd39c26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 315 zcmeAS@N?(olHy`uVBq!ia0vp^GC*v=!3HFmlBI3}DYhhUcNd1sAh?`)+ee@XXMsm# zF#`j)FbFd;%$g$s6l5>)^mS#w%freeZ&4%h9b~`>PZ!6Kh{JEE@8vyYAi~z)p(&xv zn$&d0@h}U|0j3-WK`$#VwH<+%mL#)fIJLJ3%~>w+Cn~z`m)~>yir`mKwE~e@Yp-4O zmEP*L^Vz4vKiD!FUEOALWxCzo-8JuX`2kIN4$X=G { - if (event.key === "message" && event.newValue) { - const msg = JSON.parse(event.newValue); - if ( - msg.message === "close_tabs" && - msg.session == this.pos.globalState.pos_session.id - ) { - console.info("POS / Session opened in another window. EXITING POS"); - this.pos.closePos(); - } - } - }, - false - ); - } get showCashMoveButton() { return Boolean(this.pos.globalState?.config?.cash_control); } diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 54e0c973a3a..8ed0cf49220 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -231,6 +231,8 @@ export class PosGlobalState extends PosModel { const { start_category, iface_start_categ_id } = this.config; this.selectedCategoryId = (start_category && iface_start_categ_id?.[0]) || 0; this.hasBigScrollBars = this.config.iface_big_scrollbars; + // Push orders in background, do not await + this.push_orders(); this.markReady(); } diff --git a/addons/point_of_sale/static/src/scss/pos.scss b/addons/point_of_sale/static/src/scss/pos.scss index c11374ed1d6..4cf75ed1545 100644 --- a/addons/point_of_sale/static/src/scss/pos.scss +++ b/addons/point_of_sale/static/src/scss/pos.scss @@ -145,57 +145,6 @@ td { overflow: hidden; } -/* ********* The black loading screen ********* */ - -.pos .loader{ - background-color: #222; - position:absolute; - left:0px; - top:0px; - width:100%; - height:100%; - z-index: 999; - text-align: center; - font-family: Lato; - color: $gray-700; -} - -.pos .loader-feedback{ - width: 400px; - height: 160px; - margin: -60px -200px; - position: absolute; - left: 50%; top: 50%; - text-align: center; -} -.pos .loader-feedback h1{ - font-weight: 300; -} -.pos .loader-feedback .progressbar{ - background: rgb(73,73,73); - height: 1px; -} -.pos .loader-feedback .progressbar > .progress{ - height: 100%; - background: white; - width: 0%; - box-shadow: 0px 0px 5px rgba(255,255,255,0.35); -} -.pos .loader-feedback .button{ - display: inline-block; - margin: 25px auto; - line-height: 42px; - padding: 0px 16px; - font-size: 20px; - font-weight: 300; - border: solid 1px; - border-radius: 5px; - cursor: pointer; -} -.pos .loader-feedback .button:active{ - color: #222; - background: $gray-700; -} /* ********* Generic Layout Constructs ********* */ .pos .window{ @@ -2921,14 +2870,6 @@ td { opacity: 0; } -.o-swing { - transition: opacity 0.8s; -} - -.o-swing-enter, .o-swing-leave { - opacity: 0; -} - /* We block the top-header when a temp screen is displayed. Similar to blocking the whole ui when a popup is displayed. @@ -3736,64 +3677,6 @@ td { } } -/* For LoadingScreen */ - -.lds-ellipsis { - display: inline-block; - position: relative; - width: 80px; - height: 60px; -} -.lds-ellipsis div { - position: absolute; - top: 33px; - width: 13px; - height: 13px; - border-radius: 50%; - background: #fff; - animation-timing-function: cubic-bezier(0, 1, 1, 0); -} -.lds-ellipsis div:nth-child(1) { - left: 8px; - animation: lds-ellipsis1 0.6s infinite; -} -.lds-ellipsis div:nth-child(2) { - left: 8px; - animation: lds-ellipsis2 0.6s infinite; -} -.lds-ellipsis div:nth-child(3) { - left: 32px; - animation: lds-ellipsis2 0.6s infinite; -} -.lds-ellipsis div:nth-child(4) { - left: 56px; - animation: lds-ellipsis3 0.6s infinite; -} -@keyframes lds-ellipsis1 { - 0% { - transform: scale(0); - } - 100% { - transform: scale(1); - } -} -@keyframes lds-ellipsis3 { - 0% { - transform: scale(1); - } - 100% { - transform: scale(0); - } -} -@keyframes lds-ellipsis2 { - 0% { - transform: translate(0, 0); - } - 100% { - transform: translate(24px, 0); - } -} - .menu { color: white; z-index: 1000; diff --git a/addons/point_of_sale/static/src/xml/Chrome.xml b/addons/point_of_sale/static/src/xml/Chrome.xml index e20bbdc9b41..e6d0013ba89 100644 --- a/addons/point_of_sale/static/src/xml/Chrome.xml +++ b/addons/point_of_sale/static/src/xml/Chrome.xml @@ -4,39 +4,24 @@
- - -
-
-
-
-
- - - - - - -
+ +
+
+
+
+
+ + + + +
- - - -
-
- -
- -

Connecting to devices

-
-
-
-
+
diff --git a/addons/point_of_sale/static/tests/unit/pos_app_tests.js b/addons/point_of_sale/static/tests/unit/pos_app_tests.js index 163e699aec6..b8d51f384d8 100644 --- a/addons/point_of_sale/static/tests/unit/pos_app_tests.js +++ b/addons/point_of_sale/static/tests/unit/pos_app_tests.js @@ -1,6 +1,6 @@ /** @odoo-module */ import { Chrome } from "@point_of_sale/js/Chrome"; -import { getFixture, mount, nextTick } from "@web/../tests/helpers/utils"; +import { getFixture, mount } from "@web/../tests/helpers/utils"; import { makeTestEnv } from "@web/../tests/helpers/mock_env"; import { registry } from "@web/core/registry"; import { posService } from "@point_of_sale/app/pos_store"; @@ -46,11 +46,12 @@ const serverData = { QUnit.test("mount the Chrome", async (assert) => { const fixture = getFixture(); - const root = await mount(Chrome, fixture, { + assert.verifySteps([]); + await mount(Chrome, fixture, { env: await makeTestEnv({ serverData }), test: true, + props: { disableLoader: () => assert.step("disable loader") }, }); - await root.env.services.pos.globalState.ready; - await nextTick(); assert.containsOnce(fixture, ".pos"); + assert.verifySteps(["disable loader"]); }); diff --git a/addons/pos_hr/static/src/app/pos_store.js b/addons/pos_hr/static/src/app/pos_store.js index 43acf1d2637..c97f7a5e68a 100644 --- a/addons/pos_hr/static/src/app/pos_store.js +++ b/addons/pos_hr/static/src/app/pos_store.js @@ -4,6 +4,12 @@ import { patch } from "@web/core/utils/patch"; import { PosStore } from "@point_of_sale/app/pos_store"; patch(PosStore.prototype, "pos_hr.PosStore", { + async setup() { + await this._super(...arguments); + if (this.globalState.config.module_pos_hr) { + this.showTempScreen("LoginScreen"); + } + }, /** * @override */ diff --git a/addons/pos_hr/static/src/js/Chrome.js b/addons/pos_hr/static/src/js/Chrome.js index 3a469eeae7e..a4ed3088905 100644 --- a/addons/pos_hr/static/src/js/Chrome.js +++ b/addons/pos_hr/static/src/js/Chrome.js @@ -4,12 +4,6 @@ import { Chrome } from "@point_of_sale/js/Chrome"; import { patch } from "@web/core/utils/patch"; patch(Chrome.prototype, "pos_hr.Chrome", { - async start() { - await this._super(...arguments); - if (this.env.pos.config.module_pos_hr) { - this.pos.showTempScreen("LoginScreen"); // FIXME POSREF: use startScreen instead. - } - }, get showCashMoveButton() { return ( this._super(...arguments) && diff --git a/addons/pos_restaurant/static/src/app/pos_store.js b/addons/pos_restaurant/static/src/app/pos_store.js index 89060c2eb30..68eb778af4f 100644 --- a/addons/pos_restaurant/static/src/app/pos_store.js +++ b/addons/pos_restaurant/static/src/app/pos_store.js @@ -24,13 +24,12 @@ patch(PosStore.prototype, "pos_restaurant.PosStore", { /** * @override */ - setup() { - this._super(...arguments); - this.globalState.ready.then(() => { - if (this.globalState.config.is_table_management) { - this.setActivityListeners(); - } - }); + async setup() { + await this._super(...arguments); + if (this.globalState.config.is_table_management) { + this.setActivityListeners(); + this.showScreen("FloorScreen", { floor: this.globalState.table?.floor || null }); + } }, setActivityListeners() { IDLE_TIMER_SETTER = this.setIdleTimer.bind(this); diff --git a/addons/pos_restaurant/static/src/js/Chrome.js b/addons/pos_restaurant/static/src/js/Chrome.js deleted file mode 100644 index 27f988fb1ab..00000000000 --- a/addons/pos_restaurant/static/src/js/Chrome.js +++ /dev/null @@ -1,20 +0,0 @@ -/** @odoo-module */ - -import { patch } from "@web/core/utils/patch"; -import { Chrome } from "@point_of_sale/js/Chrome"; - -patch(Chrome.prototype, "pos_restaurant.Chrome", { - /** - * @override - * FIXME POSREF move to pos store - * `FloorScreen` is the start screen if there are floors. - */ - get startScreen() { - if (this.env.pos.config.is_table_management) { - const table = this.env.pos.table; - return { name: "FloorScreen", props: { floor: table ? table.floor : null } }; - } else { - return this._super(...arguments); - } - }, -}); diff --git a/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js b/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js index 32b1c8a5102..f5e5cfcde13 100644 --- a/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js +++ b/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js @@ -83,11 +83,7 @@ patch(TicketScreen.prototype, "pos_restaurant.TicketScreen", { if (this.env.pos.config.is_table_management) { this.env.pos.setOrderToRemove(order); if (!this.env.pos.table) { - try { - await this.env.pos._removeOrdersFromServer(); - } catch (error) { - throw error; - } + await this.env.pos._removeOrdersFromServer(); } } await _super(...arguments); diff --git a/addons/web/static/src/start.js b/addons/web/static/src/start.js index 678d756571c..48515d5b031 100644 --- a/addons/web/static/src/start.js +++ b/addons/web/static/src/start.js @@ -19,7 +19,7 @@ import { App, whenReady } from "@odoo/owl"; * * @param {Component} Webclient */ -export async function startWebClient(Webclient) { +export async function startWebClient(Webclient, props = {}) { odoo.info = { db: session.db, server_version: session.server_version, @@ -39,6 +39,7 @@ export async function startWebClient(Webclient) { const app = new App(Webclient, { name: "Odoo Web Client", env, + props, templates, dev: env.debug, warnIfNoStaticProps: true,