Files
odoo_source/addons/web/static/tests/helpers/legacy.js
T
Achraf (abz) e885885d74 [FIX] web: Allow user to "search more" when adding o2m field
Steps:
  - Open studio in any list view
  - Try to add o2m to the list view
  - Select a related field
  - Click Search more
  - traceback "ViewClass is not defined"

Since https://github.com/odoo/odoo/commit/186a8b31161fc8c75b346ff97f9403dca1ae677e#diff-5e3a43184a718068d966f2ea2eb972fb54b9795a8efa5c8e8cd99ab07a4e2cdfL19
the form, kanban and list view have been removed from the registry.

opw-3020871

closes odoo/odoo#103980

X-original-commit: 19f98f7eb316a49a754eb68ea1352834a1e2a2e6
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Achraf <abz@odoo.com>
2022-10-25 13:03:39 +02:00

38 lines
1.6 KiB
JavaScript

odoo.define("web.SessionOverrideForTests", (require) => {
// Override the Session.session_reload function
// The wowl test infrastructure does set a correct odoo global value before each test
// while the session is built only once for all tests.
// 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 { 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() {
for (const key in sessionInfo) {
delete sessionInfo[key];
}
for (const key in initialSessionInfo) {
sessionInfo[key] = initialSessionInfo[key];
}
return await this._super(...arguments);
},
});
});
odoo.define("web.test_legacy", async (require) => {
require("web.SessionOverrideForTests");
require("web.test_utils");
const session = require("web.session");
await session.is_bound; // await for templates from server
const FormView = require("web.FormView");
const ListView = require("web.ListView");
const viewRegistry = require("web.view_registry");
viewRegistry.add("legacy_form", FormView).add("legacy_list", ListView);
return { legacyProm: session.is_bound };
});