diff --git a/addons/google_recaptcha/static/src/js/recaptcha.js b/addons/google_recaptcha/static/src/js/recaptcha.js
index dc6e1016c9e..812bcd5e980 100644
--- a/addons/google_recaptcha/static/src/js/recaptcha.js
+++ b/addons/google_recaptcha/static/src/js/recaptcha.js
@@ -4,6 +4,7 @@ odoo.define('google_recaptcha.ReCaptchaV3', function (require) {
const ajax = require('web.ajax');
const Class = require('web.Class');
const core = require('web.core');
+const { session } = require('@web/session');
const _t = core._t;
@@ -12,7 +13,7 @@ const ReCaptcha = Class.extend({
* @override
*/
init: function () {
- this._publicKey = odoo.session_info.recaptcha_public_key;
+ this._publicKey = session.recaptcha_public_key;
},
/**
* Loads the recaptcha libraries.
diff --git a/addons/mail/static/tests/activity_tests.js b/addons/mail/static/tests/activity_tests.js
index 92f264fb9f7..57990a3c7b9 100644
--- a/addons/mail/static/tests/activity_tests.js
+++ b/addons/mail/static/tests/activity_tests.js
@@ -9,6 +9,7 @@ import { legacyExtraNextTick, patchWithCleanup } from "@web/../tests/helpers/uti
import { createWebClient, doAction } from "@web/../tests/webclient/helpers";
import { patch, unpatch } from 'web.utils';
import { registry } from "@web/core/registry";
+import { session } from '@web/session';
let serverData;
@@ -394,7 +395,7 @@ QUnit.test("activity view: no group_by_menu and no comparison_menu", async funct
}
};
- patchWithCleanup(odoo.session_info.user_context, { lang: "zz_ZZ" });
+ patchWithCleanup(session.user_context, { lang: "zz_ZZ" });
const webClient = await createWebClient({ serverData, mockRPC , legacyParams: {withLegacyMockServer: true}});
diff --git a/addons/partner_autocomplete/static/src/js/web_company_autocomplete.js b/addons/partner_autocomplete/static/src/js/web_company_autocomplete.js
index 245abe4740b..cad69034b7a 100644
--- a/addons/partner_autocomplete/static/src/js/web_company_autocomplete.js
+++ b/addons/partner_autocomplete/static/src/js/web_company_autocomplete.js
@@ -1,12 +1,13 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
+import { session } from "@web/session";
export const companyAutocompleteService = {
dependencies: ["orm", "company"],
start(env, { orm, company }) {
- if (odoo.session_info.iap_company_enrich) {
+ if (session.iap_company_enrich) {
const currentCompanyId = company.currentCompany.id;
orm.silent.call("res.company", "iap_enrich_auto", [currentCompanyId], {});
}
diff --git a/addons/point_of_sale/views/pos_assets_index.xml b/addons/point_of_sale/views/pos_assets_index.xml
index 361a3462655..53565537b01 100644
--- a/addons/point_of_sale/views/pos_assets_index.xml
+++ b/addons/point_of_sale/views/pos_assets_index.xml
@@ -28,11 +28,11 @@
diff --git a/addons/point_of_sale/views/pos_assets_qunit.xml b/addons/point_of_sale/views/pos_assets_qunit.xml
index 920446cdbd5..5857c4bc0e6 100644
--- a/addons/point_of_sale/views/pos_assets_qunit.xml
+++ b/addons/point_of_sale/views/pos_assets_qunit.xml
@@ -32,7 +32,7 @@
diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py
index e32539890e0..7fd1cfcc0d3 100644
--- a/addons/web/__manifest__.py
+++ b/addons/web/__manifest__.py
@@ -57,6 +57,7 @@ This module provides the core of the Odoo Web Client.
'web/static/lib/es6-promise/es6-promise-polyfill.js',
'web/static/src/legacy/js/promise_extension.js',
'web/static/src/boot.js',
+ 'web/static/src/session.js',
],
'web.assets_common': [
('include', 'web._assets_helpers'),
@@ -73,6 +74,7 @@ This module provides the core of the Odoo Web Client.
('remove', 'web/static/lib/es6-promise/es6-promise-polyfill.js'),
('remove', 'web/static/src/legacy/js/promise_extension.js'),
('remove', 'web/static/src/boot.js'),
+ ('remove', 'web/static/src/session.js'),
],
'web.assets_backend': [
('include', 'web._assets_helpers'),
diff --git a/addons/web/static/src/core/debug/profiling/profiling_service.js b/addons/web/static/src/core/debug/profiling/profiling_service.js
index 0f67e5e92de..8baff977a27 100644
--- a/addons/web/static/src/core/debug/profiling/profiling_service.js
+++ b/addons/web/static/src/core/debug/profiling/profiling_service.js
@@ -2,17 +2,17 @@
import { registry } from "@web/core/registry";
import { ProfilingItem } from "./profiling_item";
+import { session } from "@web/session";
const { core } = owl;
const profilingService = {
dependencies: ["orm"],
start(env, { orm }) {
- const sessionInfo = odoo.session_info;
const state = {
- session: sessionInfo.profile_session || false,
- collectors: sessionInfo.profile_collectors || ["sql", "traces_async"],
- params: sessionInfo.profile_params || {},
+ session: session.profile_session || false,
+ collectors: session.profile_collectors || ["sql", "traces_async"],
+ params: session.profile_params || {},
get isEnabled() {
return Boolean(state.session);
},
diff --git a/addons/web/static/src/core/l10n/currency.js b/addons/web/static/src/core/l10n/currency.js
index 4fc3844493d..93ceadf3233 100644
--- a/addons/web/static/src/core/l10n/currency.js
+++ b/addons/web/static/src/core/l10n/currency.js
@@ -1,6 +1,7 @@
/** @odoo-module **/
import { formatFloat, humanNumber, parseFloat, InvalidNumberError } from "./numbers";
+import { session } from "@web/session";
/**
* Formats a value as a currency.
@@ -20,7 +21,7 @@ export function formatCurrency(value, cid, options = {}) {
if (value === false) {
return "";
}
- const currency = odoo.session_info.currencies[cid];
+ const currency = session.currencies[cid];
const { noSymbol } = options || {};
const digits = (currency && currency.digits) || options.digits;
@@ -56,9 +57,9 @@ export function parseCurrency(value, options = {}) {
}
let currency;
if (options.currencyId) {
- currency = odoo.session_info.currencies[options.currencyId];
+ currency = session.currencies[options.currencyId];
} else {
- currency = Object.values(odoo.session_info.currencies)[0];
+ currency = Object.values(session.currencies)[0];
}
const symbolIndex = values.findIndex((v) => v === currency.symbol);
if (symbolIndex === -1) {
diff --git a/addons/web/static/src/core/l10n/localization_service.js b/addons/web/static/src/core/l10n/localization_service.js
index 5163869341b..bd715f0d1ff 100644
--- a/addons/web/static/src/core/l10n/localization_service.js
+++ b/addons/web/static/src/core/l10n/localization_service.js
@@ -5,11 +5,12 @@ import { registry } from "../registry";
import { strftimeToLuxonFormat } from "./dates";
import { localization } from "./localization";
import { translatedTerms, _t } from "./translation";
+import { session } from "@web/session";
export const localizationService = {
dependencies: ["user"],
start: async (env, { user }) => {
- const cacheHashes = odoo.session_info.cache_hashes;
+ const cacheHashes = session.cache_hashes;
const translationsHash = cacheHashes.translations || new Date().getTime().toString();
const lang = user.lang || null;
let url = `/web/webclient/translations/${translationsHash}`;
diff --git a/addons/web/static/src/core/user_service.js b/addons/web/static/src/core/user_service.js
index 4a701687646..a1c627d0352 100644
--- a/addons/web/static/src/core/user_service.js
+++ b/addons/web/static/src/core/user_service.js
@@ -1,17 +1,17 @@
/** @odoo-module **/
import { registry } from "./registry";
+import { session } from "@web/session";
export const userService = {
dependencies: ["rpc"],
async: ["hasGroup"],
start(env, { rpc }) {
- const sessionInfo = odoo.session_info;
const groupProms = {};
const context = {
- ...sessionInfo.user_context,
- uid: sessionInfo.uid,
+ ...session.user_context,
+ uid: session.uid,
};
return {
get context() {
@@ -37,13 +37,13 @@ export const userService = {
}
return groupProms[group];
},
- name: sessionInfo.name,
- userName: sessionInfo.username,
- isAdmin: sessionInfo.is_admin,
- isSystem: sessionInfo.is_system,
- partnerId: sessionInfo.partner_id,
- home_action_id: sessionInfo.home_action_id,
- showEffect: sessionInfo.show_effect,
+ name: session.name,
+ userName: session.username,
+ isAdmin: session.is_admin,
+ isSystem: session.is_system,
+ partnerId: session.partner_id,
+ home_action_id: session.home_action_id,
+ showEffect: session.show_effect,
get userId() {
return context.uid;
},
@@ -55,10 +55,10 @@ export const userService = {
},
get db() {
const res = {
- name: sessionInfo.db,
+ name: session.db,
};
- if ("dbuuid" in sessionInfo) {
- res.uuid = sessionInfo.dbuuid;
+ if ("dbuuid" in session) {
+ res.uuid = session.dbuuid;
}
return res;
},
diff --git a/addons/web/static/src/legacy/frontend/debug_manager/debug_manager.js b/addons/web/static/src/legacy/frontend/debug_manager/debug_manager.js
index 09a9fd56497..505e227a6eb 100644
--- a/addons/web/static/src/legacy/frontend/debug_manager/debug_manager.js
+++ b/addons/web/static/src/legacy/frontend/debug_manager/debug_manager.js
@@ -5,6 +5,7 @@ var core = require('web.core');
var session = require('web.session');
var utils = require('web.utils');
var Widget = require('web.Widget');
+const { session: sessionInfo } = require('@web/session');
var QWeb = core.qweb;
@@ -25,12 +26,12 @@ var DebugManager = Widget.extend({
var debug = odoo.debug;
this.debug_mode = debug;
this.debug_mode_help = debug && debug !== '1' ? ' (' + debug + ')' : '';
- this.profile_session = odoo.session_info && odoo.session_info.profile_session || false;
- this.profile_collectors = odoo.session_info && odoo.session_info.profile_collectors;
+ this.profile_session = sessionInfo.profile_session || false;
+ this.profile_collectors = sessionInfo.profile_collectors;
if (! Array.isArray(this.profile_collectors)) {
this.profile_collectors = ['sql', 'traces_async']; // use default value when not defined in session.
}
- this.profile_params = odoo.session_info && odoo.session_info.profile_params || {};
+ this.profile_params = sessionInfo.profile_params || {};
},
start: function () {
core.bus.on('rpc:result', this, function (req, resp) {
diff --git a/addons/web/static/src/legacy/js/core/ajax.js b/addons/web/static/src/legacy/js/core/ajax.js
index 68b5b5ae451..1ec31f8bdd8 100644
--- a/addons/web/static/src/legacy/js/core/ajax.js
+++ b/addons/web/static/src/legacy/js/core/ajax.js
@@ -7,6 +7,7 @@ var core = require('web.core');
var time = require('web.time');
var download = require('web.download');
var contentdisposition = require('web.contentdisposition');
+const { session } = require('@web/session');
var _t = core._t;
@@ -437,7 +438,7 @@ var loadAsset = (function () {
if (cache[xmlId]) {
return cache[xmlId];
}
- context = _.extend({}, odoo.session_info.user_context, context);
+ context = _.extend({}, session.user_context, context);
const params = {
args: [xmlId, {
debug: config.isDebug()
diff --git a/addons/web/static/src/legacy/js/core/session.js b/addons/web/static/src/legacy/js/core/session.js
index 8e47e4c06fa..3da533e73c9 100644
--- a/addons/web/static/src/legacy/js/core/session.js
+++ b/addons/web/static/src/legacy/js/core/session.js
@@ -6,6 +6,7 @@ var concurrency = require('web.concurrency');
var core = require('web.core');
var mixins = require('web.mixins');
var utils = require('web.utils');
+const { session } = require('@web/session');
var _t = core._t;
var qweb = core.qweb;
@@ -258,7 +259,7 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
* @returns {Promise} promise indicating the session is done reloading
*/
session_reload: function () {
- var result = _.extend({}, window.odoo.session_info);
+ var result = _.extend({}, session);
_.extend(this, result);
return Promise.resolve();
},
diff --git a/addons/web/static/src/session.js b/addons/web/static/src/session.js
new file mode 100644
index 00000000000..eada26e3b5b
--- /dev/null
+++ b/addons/web/static/src/session.js
@@ -0,0 +1,4 @@
+/** @odoo-module **/
+
+export const session = odoo.__session_info__ || {};
+delete odoo.__session_info__;
diff --git a/addons/web/static/src/start.js b/addons/web/static/src/start.js
index 237361c5eeb..273341f882d 100644
--- a/addons/web/static/src/start.js
+++ b/addons/web/static/src/start.js
@@ -4,6 +4,7 @@ import { makeEnv, startServices } from "./env";
import { legacySetupProm } from "./legacy/legacy_setup";
import { mapLegacyEnvToWowlEnv } from "./legacy/utils";
import { processTemplates } from "./core/assets";
+import { session } from "@web/session";
const { mount, utils } = owl;
const { whenReady } = utils;
@@ -17,13 +18,11 @@ const { whenReady } = utils;
* @param {owl.Component} Webclient
*/
export async function startWebClient(Webclient) {
- // delete (odoo as any).session_info; // FIXME: some legacy code rely on this (e.g. ajax.js)
- const sessionInfo = odoo.session_info;
odoo.info = {
- db: sessionInfo.db,
- server_version: sessionInfo.server_version,
- server_version_info: sessionInfo.server_version_info,
- isEnterprise: sessionInfo.server_version_info.slice(-1)[0] === "e",
+ 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;
diff --git a/addons/web/static/src/webclient/company_service.js b/addons/web/static/src/webclient/company_service.js
index 5167c65e85f..c669b77b9a0 100644
--- a/addons/web/static/src/webclient/company_service.js
+++ b/addons/web/static/src/webclient/company_service.js
@@ -3,6 +3,7 @@
import { browser } from "@web/core/browser/browser";
import { registry } from "@web/core/registry";
import { symmetricalDifference } from "../core/utils/arrays";
+import { session } from "@web/session";
function parseCompanyIds(cidsFromHash) {
const cids = [];
@@ -15,7 +16,7 @@ function parseCompanyIds(cidsFromHash) {
}
function computeAllowedCompanyIds(cids) {
- const { user_companies } = odoo.session_info;
+ const { user_companies } = session;
let allowedCompanyIds = cids || [];
const availableCompaniesFromSession = user_companies.allowed_companies;
const notReallyAllowedCompanies = allowedCompanyIds.filter(
@@ -44,7 +45,7 @@ export const companyService = {
cookie.setCookie("cids", stringCIds);
user.updateContext({ allowed_company_ids: allowedCompanyIds });
- const availableCompanies = odoo.session_info.user_companies.allowed_companies;
+ const availableCompanies = session.user_companies.allowed_companies;
return {
availableCompanies,
diff --git a/addons/web/static/src/webclient/menu_service.js b/addons/web/static/src/webclient/menu_service.js
index 92514101312..4a8433fd1ea 100644
--- a/addons/web/static/src/webclient/menu_service.js
+++ b/addons/web/static/src/webclient/menu_service.js
@@ -2,11 +2,12 @@
import { browser } from "../core/browser/browser";
import { registry } from "../core/registry";
+import { session } from "@web/session";
const loadMenusUrl = `/web/webclient/load_menus`;
function makeFetchLoadMenus() {
- const cacheHashes = odoo.session_info.cache_hashes;
+ const cacheHashes = session.cache_hashes;
let loadMenusHash = cacheHashes.load_menus || new Date().getTime().toString();
return async function fetchLoadMenus(reload) {
if (reload) {
diff --git a/addons/web/static/src/webclient/user_menu/user_menu_items.js b/addons/web/static/src/webclient/user_menu/user_menu_items.js
index 826ce6d11fa..bac6b3527bf 100644
--- a/addons/web/static/src/webclient/user_menu/user_menu_items.js
+++ b/addons/web/static/src/webclient/user_menu/user_menu_items.js
@@ -4,6 +4,7 @@ import { Dialog } from "../../core/dialog/dialog";
import { browser } from "../../core/browser/browser";
import { registry } from "../../core/registry";
import { _lt } from "../../core/l10n/translation";
+import { session } from "@web/session";
function documentationItem(env) {
const documentationURL = "https://www.odoo.com/documentation/14.0";
@@ -20,7 +21,7 @@ function documentationItem(env) {
}
function supportItem(env) {
- const url = odoo.session_info.support_url;
+ const url = session.support_url;
return {
type: "item",
id: "support",
diff --git a/addons/web/static/tests/core/l10n/currency_tests.js b/addons/web/static/tests/core/l10n/currency_tests.js
index fa6c540f55c..515b7a87f9a 100644
--- a/addons/web/static/tests/core/l10n/currency_tests.js
+++ b/addons/web/static/tests/core/l10n/currency_tests.js
@@ -5,6 +5,7 @@ import { localization } from "@web/core/l10n/localization";
import { patch, unpatch } from "@web/core/utils/patch";
import { defaultLocalization } from "../../helpers/mock_services";
import { patchWithCleanup } from "@web/../tests/helpers/utils";
+import { session } from "@web/session";
QUnit.module("utils", (hooks) => {
hooks.beforeEach(() => {
@@ -34,7 +35,7 @@ QUnit.module("utils", (hooks) => {
QUnit.test("parseCurrency", function (assert) {
assert.expect(17);
- patchWithCleanup(odoo.session_info, {
+ patchWithCleanup(session, {
currencies: {
1: {
digits: [69, 2],
diff --git a/addons/web/static/tests/helpers/legacy.js b/addons/web/static/tests/helpers/legacy.js
index 931f2b67ebd..7d171168779 100644
--- a/addons/web/static/tests/helpers/legacy.js
+++ b/addons/web/static/tests/helpers/legacy.js
@@ -5,16 +5,17 @@ odoo.define("web.SessionOverrideForTests", (require) => {
// So if a test does a session_reload, it will merge the odoo global of that test
// into the session, and will alter every subsequent test of the suite.
// Obviously, we don't want that, ever.
- const initialOdoo = Object.assign({}, odoo);
+ const { session: sessionInfo } = require("@web/session");
+ const initialSessionInfo = Object.assign({}, sessionInfo);
const Session = require("web.Session");
const { patch } = require("@web/core/utils/patch");
patch(Session.prototype, "web.SessionTestPatch", {
async session_reload() {
- const oldOdoo = odoo;
- odoo = initialOdoo;
- const res = await this._super(...arguments);
- odoo = oldOdoo;
- return res;
+ for (const key in sessionInfo) delete sessionInfo[key];
+ for (const key in initialSessionInfo) {
+ sessionInfo[key] = initialSessionInfo[key];
+ }
+ return await this._super(...arguments);
},
});
});
diff --git a/addons/web/static/tests/setup.js b/addons/web/static/tests/setup.js
index 4d69924bcfe..6143793a7a8 100644
--- a/addons/web/static/tests/setup.js
+++ b/addons/web/static/tests/setup.js
@@ -8,6 +8,7 @@ import { patchWithCleanup } from "@web/../tests/helpers/utils";
import { legacyProm } from "web.test_legacy";
import { registerCleanup } from "./helpers/cleanup";
import { prepareRegistriesWithCleanup } from "./helpers/mock_env";
+import { session as sessionInfo } from "@web/session";
const { whenReady, loadFile } = owl.utils;
@@ -148,37 +149,40 @@ function patchLegacyCoreBus() {
function patchOdoo() {
patchWithCleanup(odoo, {
debug: "",
- session_info: {
- cache_hashes: {
- load_menus: "161803",
- translations: "314159",
- },
- currencies: {
- 1: { name: "USD", digits: [69, 2], position: "before", symbol: "$" },
- 2: { name: "EUR", digits: [69, 2], position: "after", symbol: "€" },
- },
- user_context: {
- lang: "en",
- uid: 7,
- tz: "taht",
- },
- qweb: "owl",
- uid: 7,
- name: "Mitchell",
- username: "The wise",
- is_admin: true,
- is_system: true,
- partner_id: 7,
- // Commit: 3e847fc8f499c96b8f2d072ab19f35e105fd7749
- // to see what user_companies is
- user_companies: {
- allowed_companies: { 1: { id: 1, name: "Hermit" } },
- current_company: 1,
- },
- db: "test",
- server_version: "1.0",
- server_version_info: ["1.0"],
+ });
+}
+
+function patchSessionInfo() {
+ patchWithCleanup(sessionInfo, {
+ cache_hashes: {
+ load_menus: "161803",
+ translations: "314159",
},
+ currencies: {
+ 1: { name: "USD", digits: [69, 2], position: "before", symbol: "$" },
+ 2: { name: "EUR", digits: [69, 2], position: "after", symbol: "€" },
+ },
+ user_context: {
+ lang: "en",
+ uid: 7,
+ tz: "taht",
+ },
+ qweb: "owl",
+ uid: 7,
+ name: "Mitchell",
+ username: "The wise",
+ is_admin: true,
+ is_system: true,
+ partner_id: 7,
+ // Commit: 3e847fc8f499c96b8f2d072ab19f35e105fd7749
+ // to see what user_companies is
+ user_companies: {
+ allowed_companies: { 1: { id: 1, name: "Hermit" } },
+ current_company: 1,
+ },
+ db: "test",
+ server_version: "1.0",
+ server_version_info: ["1.0"],
});
}
@@ -190,6 +194,7 @@ export async function setupTests() {
patchBrowserWithCleanup();
patchLegacyCoreBus();
patchOdoo();
+ patchSessionInfo();
});
const templatesUrl = `/web/webclient/qweb/${new Date().getTime()}?bundle=web.assets_qweb`;
diff --git a/addons/web/static/tests/webclient/actions/effects_tests.js b/addons/web/static/tests/webclient/actions/effects_tests.js
index 5f8109daa0b..607131d1441 100644
--- a/addons/web/static/tests/webclient/actions/effects_tests.js
+++ b/addons/web/static/tests/webclient/actions/effects_tests.js
@@ -5,6 +5,7 @@ import testUtils from "web.test_utils";
import { clearRegistryWithCleanup } from "../../helpers/mock_env";
import { click, legacyExtraNextTick, nextTick, patchWithCleanup } from "../../helpers/utils";
import { createWebClient, doAction, getActionManagerServerData } from "./../helpers";
+import { session } from "@web/session";
let serverData;
@@ -19,7 +20,7 @@ QUnit.module("ActionManager", (hooks) => {
QUnit.test("rainbowman integrated to webClient", async function (assert) {
assert.expect(10);
- patchWithCleanup(odoo.session_info, { show_effect: true });
+ patchWithCleanup(session, { show_effect: true });
clearRegistryWithCleanup(mainComponentRegistry);
const webClient = await createWebClient({ serverData });
@@ -65,7 +66,7 @@ QUnit.module("ActionManager", (hooks) => {
QUnit.test("on close with effect from server", async function (assert) {
assert.expect(1);
- patchWithCleanup(odoo.session_info, { show_effect: true });
+ patchWithCleanup(session, { show_effect: true });
const mockRPC = async (route) => {
if (route === "/web/dataset/call_button") {
return Promise.resolve({
@@ -96,7 +97,7 @@ QUnit.module("ActionManager", (hooks) => {
`;
- patchWithCleanup(odoo.session_info, { show_effect: true });
+ patchWithCleanup(session, { show_effect: true });
const mockRPC = async (route) => {
if (route === "/web/dataset/call_button") {
return Promise.resolve(false);
diff --git a/addons/web/static/tests/webclient/actions/load_state_tests.js b/addons/web/static/tests/webclient/actions/load_state_tests.js
index 4d5743f9d53..0b8add47976 100644
--- a/addons/web/static/tests/webclient/actions/load_state_tests.js
+++ b/addons/web/static/tests/webclient/actions/load_state_tests.js
@@ -8,7 +8,14 @@ import core from "web.core";
import AbstractAction from "web.AbstractAction";
import { registerCleanup } from "../../helpers/cleanup";
import { makeTestEnv } from "../../helpers/mock_env";
-import { click, getFixture, legacyExtraNextTick, patchWithCleanup, nextTick } from "../../helpers/utils";
+import {
+ click,
+ getFixture,
+ legacyExtraNextTick,
+ patchWithCleanup,
+ nextTick,
+} from "../../helpers/utils";
+import { session } from "@web/session";
import {
createWebClient,
doAction,
@@ -104,7 +111,7 @@ QUnit.module("ActionManager", (hooks) => {
QUnit.test("fallback on home action if no action found", async (assert) => {
assert.expect(2);
- patchWithCleanup(odoo.session_info, { home_action_id: 1001 });
+ patchWithCleanup(session, { home_action_id: 1001 });
const wc = await createWebClient({ serverData });
await testUtils.nextTick(); // wait for the navbar to be updated
diff --git a/addons/web/static/tests/webclient/actions/report_action_tests.js b/addons/web/static/tests/webclient/actions/report_action_tests.js
index c445c026457..c47ad12e93e 100644
--- a/addons/web/static/tests/webclient/actions/report_action_tests.js
+++ b/addons/web/static/tests/webclient/actions/report_action_tests.js
@@ -9,6 +9,7 @@ import { patchWithCleanup } from "../../helpers/utils";
import { createWebClient, doAction, getActionManagerServerData } from "./../helpers";
import { mockDownload } from "@web/../tests/helpers/utils";
import { clearRegistryWithCleanup } from "../../helpers/mock_env";
+import { session } from "@web/session";
let serverData;
@@ -184,7 +185,7 @@ QUnit.module("ActionManager", (hooks) => {
() => {}
)
);
- patchWithCleanup(odoo.session_info.user_context, { some_key: 2 });
+ patchWithCleanup(session.user_context, { some_key: 2 });
const mockRPC = async (route, args) => {
assert.step(args.method || route);
if (route.includes("/report/html/some_report")) {
diff --git a/addons/web/static/tests/webclient/actions/window_action_tests.js b/addons/web/static/tests/webclient/actions/window_action_tests.js
index 38d8536ad68..85ef9fad507 100644
--- a/addons/web/static/tests/webclient/actions/window_action_tests.js
+++ b/addons/web/static/tests/webclient/actions/window_action_tests.js
@@ -10,6 +10,7 @@ import FormView from "web.FormView";
import ListController from "web.ListController";
import testUtils from "web.test_utils";
import legacyViewRegistry from "web.view_registry";
+import { session } from "@web/session";
import {
click,
legacyExtraNextTick,
@@ -712,7 +713,7 @@ QUnit.module("ActionManager", (hooks) => {
QUnit.test("requests for execute_action of type object are handled", async function (assert) {
assert.expect(11);
- patchWithCleanup(odoo.session_info.user_context, { some_key: 2 });
+ patchWithCleanup(session.user_context, { some_key: 2 });
const mockRPC = async (route, args) => {
assert.step((args && args.method) || route);
if (route === "/web/dataset/call_button") {
diff --git a/addons/web/static/tests/webclient/effects/rainbow_man_tests.js b/addons/web/static/tests/webclient/effects/rainbow_man_tests.js
index 892048171e3..454e0d5c2ab 100644
--- a/addons/web/static/tests/webclient/effects/rainbow_man_tests.js
+++ b/addons/web/static/tests/webclient/effects/rainbow_man_tests.js
@@ -7,6 +7,7 @@ import { RainbowMan } from "@web/webclient/effects/rainbow_man";
import { userService } from "@web/core/user_service";
import { makeTestEnv } from "../../helpers/mock_env";
import { click, getFixture, nextTick, patchWithCleanup } from "../../helpers/utils";
+import { session } from "@web/session";
const { Component, mount, tags } = owl;
const serviceRegistry = registry.category("services");
@@ -31,7 +32,7 @@ QUnit.module("RainbowMan", (hooks) => {
fadeout: "nextTick",
};
target = getFixture();
- patchWithCleanup(odoo.session_info, { show_effect: true });
+ patchWithCleanup(session, { show_effect: true });
serviceRegistry.add("user", userService);
serviceRegistry.add("effect", effectService);
serviceRegistry.add("notification", notificationService);
diff --git a/addons/web/static/tests/webclient/switch_company_menu_tests.js b/addons/web/static/tests/webclient/switch_company_menu_tests.js
index 0d72c9e469a..9bf0ad36b5f 100644
--- a/addons/web/static/tests/webclient/switch_company_menu_tests.js
+++ b/addons/web/static/tests/webclient/switch_company_menu_tests.js
@@ -9,6 +9,7 @@ import { makeTestEnv } from "../helpers/mock_env";
import { companyService } from "@web/webclient/company_service";
import { click, getFixture, makeDeferred, patchWithCleanup } from "../helpers/utils";
import { uiService } from "@web/core/ui/ui_service";
+import { session } from "@web/session";
const { mount } = owl;
const serviceRegistry = registry.category("services");
@@ -37,7 +38,7 @@ async function createSwitchCompanyMenu(routerParams = {}, toggleDelay = 0) {
QUnit.module("SwitchCompanyMenu", (hooks) => {
hooks.beforeEach(() => {
- patchWithCleanup(odoo.session_info.user_companies, {
+ patchWithCleanup(session.user_companies, {
allowed_companies: {
1: { id: 1, name: "Hermit" },
2: { id: 2, name: "Herman's" },
diff --git a/addons/web/static/tests/webclient/user_menu_tests.js b/addons/web/static/tests/webclient/user_menu_tests.js
index dd9299d3e94..9824f46f98c 100644
--- a/addons/web/static/tests/webclient/user_menu_tests.js
+++ b/addons/web/static/tests/webclient/user_menu_tests.js
@@ -12,6 +12,7 @@ import { userService } from "@web/core/user_service";
import { makeTestEnv } from "../helpers/mock_env";
import { makeFakeLocalizationService } from "../helpers/mock_services";
import { click, getFixture, patchWithCleanup } from "../helpers/utils";
+import { session } from "@web/session";
const { mount } = owl;
const serviceRegistry = registry.category("services");
@@ -22,7 +23,7 @@ let userMenu;
QUnit.module("UserMenu", {
async beforeEach() {
- patchWithCleanup(odoo.session_info, { name: "Sauron" });
+ patchWithCleanup(session, { name: "Sauron" });
serviceRegistry.add("user", userService);
serviceRegistry.add("hotkey", hotkeyService);
serviceRegistry.add("ui", uiService);
diff --git a/addons/web/static/tests/webclient/webclient_tests.js b/addons/web/static/tests/webclient/webclient_tests.js
index c7092471cac..9fedd7f0d9e 100644
--- a/addons/web/static/tests/webclient/webclient_tests.js
+++ b/addons/web/static/tests/webclient/webclient_tests.js
@@ -13,6 +13,7 @@ import { WebClient } from "@web/webclient/webclient";
import { clearRegistryWithCleanup, makeTestEnv } from "../helpers/mock_env";
import { fakeTitleService } from "../helpers/mock_services";
import { getFixture, patchWithCleanup, triggerEvent } from "../helpers/utils";
+import { session } from "@web/session";
const { Component, tags, mount } = owl;
const { xml } = tags;
@@ -61,7 +62,7 @@ QUnit.test("can render a main component", async (assert) => {
QUnit.test("webclient for the superuser", async (assert) => {
assert.expect(1);
- patchWithCleanup(odoo.session_info, { uid: 1 });
+ patchWithCleanup(session, { uid: 1 });
const env = await makeTestEnv(baseConfig);
const target = getFixture();
const webClient = await mount(WebClient, { env, target });
@@ -71,7 +72,7 @@ QUnit.test("webclient for the superuser", async (assert) => {
QUnit.test("webclient for a non superuser", async (assert) => {
assert.expect(1);
- patchWithCleanup(odoo.session_info, { uid: 2 });
+ patchWithCleanup(session, { uid: 2 });
const env = await makeTestEnv(baseConfig);
const target = getFixture();
const webClient = await mount(WebClient, { env, target });
diff --git a/addons/web/views/report_templates.xml b/addons/web/views/report_templates.xml
index 1eed00c86b9..bf804e209ee 100644
--- a/addons/web/views/report_templates.xml
+++ b/addons/web/views/report_templates.xml
@@ -19,7 +19,7 @@
diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml
index e74a5c8f650..6078891b588 100644
--- a/addons/web/views/webclient_templates.xml
+++ b/addons/web/views/webclient_templates.xml
@@ -41,7 +41,7 @@