*: 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) <jcb@odoo.com>
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
/** @odoo-module **/
|
|
|
|
import { makeEnv, startServices } from "./env";
|
|
import { legacySetupProm } from "./legacy/legacy_setup";
|
|
import { mapLegacyEnvToWowlEnv } from "./legacy/utils";
|
|
import { localization } from "@web/core/l10n/localization";
|
|
import { session } from "@web/session";
|
|
import { renderToString } from "./core/utils/render";
|
|
import { setLoadXmlDefaultApp, templates } from "@web/core/assets";
|
|
import { hasTouch } from "@web/core/browser/feature_detection";
|
|
|
|
import { App, whenReady } from "@odoo/owl";
|
|
|
|
/**
|
|
* Function to start a webclient.
|
|
* It is used both in community and enterprise in main.js.
|
|
* It's meant to be webclient flexible so we can have a subclass of
|
|
* webclient in enterprise with added features.
|
|
*
|
|
* @param {Component} Webclient
|
|
*/
|
|
export async function startWebClient(Webclient, props = {}) {
|
|
odoo.info = {
|
|
db: session.db,
|
|
server_version: session.server_version,
|
|
server_version_info: session.server_version_info,
|
|
isEnterprise: session.server_version_info.slice(-1)[0] === "e",
|
|
};
|
|
odoo.isReady = false;
|
|
|
|
// setup environment
|
|
const env = makeEnv();
|
|
await startServices(env);
|
|
|
|
// start web client
|
|
await whenReady();
|
|
const legacyEnv = await legacySetupProm;
|
|
mapLegacyEnvToWowlEnv(legacyEnv, env);
|
|
const app = new App(Webclient, {
|
|
name: "Odoo Web Client",
|
|
env,
|
|
props,
|
|
templates,
|
|
dev: env.debug,
|
|
warnIfNoStaticProps: true,
|
|
translatableAttributes: ["data-tooltip"],
|
|
translateFn: env._t,
|
|
});
|
|
renderToString.app = app;
|
|
setLoadXmlDefaultApp(app);
|
|
const root = await app.mount(document.body);
|
|
const classList = document.body.classList;
|
|
if (localization.direction === "rtl") {
|
|
classList.add("o_rtl");
|
|
}
|
|
if (env.services.user.userId === 1) {
|
|
classList.add("o_is_superuser");
|
|
}
|
|
if (env.debug) {
|
|
classList.add("o_debug");
|
|
}
|
|
if (hasTouch()) {
|
|
classList.add("o_touch_device");
|
|
}
|
|
// delete odoo.debug; // FIXME: some legacy code rely on this
|
|
odoo.__WOWL_DEBUG__ = { root };
|
|
odoo.isReady = true;
|
|
}
|