summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/main.js
blob: 465ea0d63d460bdf38977028384d47cdeee5b41d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
odoo.define('web.web_client', function (require) {
    "use strict";

    const AbstractService = require('web.AbstractService');
    const env = require('web.env');
    const session = require("web.session");
    const WebClient = require('web.WebClient');

    // configure the env and set it on Owl Component
    owl.config.mode = env.isDebug() ? "dev" : "prod";
    owl.Component.env = env;

    // deploy services in the env
    AbstractService.prototype.deployServices(env);

    // add the owl templates to the environment and start the web client
    const webClient = new WebClient();
    async function startWebClient() {
        await session.is_bound;
        env.qweb.addTemplates(session.owlTemplates);

        await owl.utils.whenReady();
        webClient.setElement($(document.body));
        webClient.start();
    }
    startWebClient();

    return webClient;
});