From 606bae9e9218d45b7babe91d4feb8f7d1ffba120 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 15 Jan 2019 16:15:42 +0000 Subject: [PATCH] [FIX] web_tour: ensure Tip template is loaded The 500 page has `session.is_frontend === undefined` as it has its own whole HTML template. In that case, the ajax.loadXML is not done, making the tour crash when visiting a 500 error page. This is needed for #29957 that has a test tour on 500 error page. closes odoo/odoo#30240 --- addons/web_tour/__manifest__.py | 2 +- addons/web_tour/static/src/js/tip.js | 1 + addons/web_tour/static/src/js/tour_service.js | 26 +++++++------------ 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/addons/web_tour/__manifest__.py b/addons/web_tour/__manifest__.py index 80f44db9165..5ff9710e855 100644 --- a/addons/web_tour/__manifest__.py +++ b/addons/web_tour/__manifest__.py @@ -21,7 +21,7 @@ Odoo Web tours. 'data/web_tour_demo.xml', ], 'qweb': [ - "static/src/xml/*.xml", + "static/src/xml/debug_manager.xml", ], 'auto_install': True } diff --git a/addons/web_tour/static/src/js/tip.js b/addons/web_tour/static/src/js/tip.js index 971af4e7c7f..8b3a8d04566 100644 --- a/addons/web_tour/static/src/js/tip.js +++ b/addons/web_tour/static/src/js/tip.js @@ -8,6 +8,7 @@ var _t = core._t; var Tip = Widget.extend({ template: "Tip", + xmlDependencies: ['/web_tour/static/src/xml/tip.xml'], events: { click: '_onTipClicked', mouseenter: "_to_info_mode", diff --git a/addons/web_tour/static/src/js/tour_service.js b/addons/web_tour/static/src/js/tour_service.js index 75e2b4daa8d..b0507d22e43 100644 --- a/addons/web_tour/static/src/js/tour_service.js +++ b/addons/web_tour/static/src/js/tour_service.js @@ -61,12 +61,8 @@ return session.is_bound.then(function () { }, 500); var observer = new MutationObserver(check_tooltip); var start_service = (function () { - var load_def; return function (observe) { - if (load_def === undefined && observe && session.is_frontend) { - load_def = ajax.loadXML('/web_tour/static/src/xml/tip.xml', QWeb); - } var def = $.Deferred(); $(function () { @@ -74,18 +70,16 @@ return session.is_bound.then(function () { * Once the DOM is ready, we still have to wait all the modules are loaded before completing the tours * registration and starting listening for DOM mutations. */ - $.when(load_def).then(function () { - _.defer(function () { - tour_manager._register_all(observe); - if (observe) { - observer.observe(document.body, { - attributes: true, - childList: true, - subtree: true, - }); - } - def.resolve(); - }); + _.defer(function () { + tour_manager._register_all(observe); + if (observe) { + observer.observe(document.body, { + attributes: true, + childList: true, + subtree: true, + }); + } + def.resolve(); }); }); return def;