[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
This commit is contained in:
qsm-odoo
2019-01-17 11:53:09 +00:00
committed by Romain Derie
parent b5fe23055d
commit 606bae9e92
3 changed files with 12 additions and 17 deletions
+1 -1
View File
@@ -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
}
+1
View File
@@ -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",
+10 -16
View File
@@ -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;