*: l10n_ae_pos, l10n_co_pos, l10n_fr_pos_cert, l10n_gcc_pos, l10n_in_pos, l10n_sa_pos, point_of_sale, pos_adyen, pos_discount, pos_epson_printer, pos_epson_printer_restaurant, pos_hr, pos_hr_restaurant, pos_loyalty, pos_mercury, pos_restaurant, pos_restaurant_adyen, pos_restaurant_stripe, pos_sale, pos_sale_loyalty, pos_sale_product_configurator, pos_six, pos_stripe, web Previously, the pos assets included almost the entirety of the assets_backend. Most of the contents of the assets_backend is completely useless in the PoS, meaning that the PoS will load slower because it loads much more JS than it needs. It also means that it gets all the side effects of this bundle (global event listeners, among other things) that we don't want. This commit removes the dependency of the pos assets on the assets_backend to solve these issues. The pos assets are now their own bundle with only what is needed in the PoS. As for the unit testing bundle, the same logic applies but unfortunately, because the unit testing code from web that we want to use (eg automatic cleanups, cleaning of registries, etc) depends on the legacy code, we need to include a lot more files than would otherwise be needed. This situation will probably be improved as legacy code is removed from web, but in the mean time, it is not very important for this bundle to be lean, as it's a test bundle and loading speed is less important. Linked to: odoo/enterprise#40502 closes odoo/odoo#120070 Related: odoo/upgrade#4626 Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
68 lines
2.1 KiB
JavaScript
68 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) {
|
|
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,
|
|
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;
|
|
}
|