[FIX] web_tour: clear inconsistent localstorage keys

When users switch from one version to another, the localstorage is not
cleared and users can get errors because the tour manager is trying to
load steps (according to the localstorage content) which could not
exist anymore.

This could also happen when a module which extends another module tour
is installed.
This commit is contained in:
qsm-odoo
2016-09-09 12:01:24 +02:00
parent 975cb36cef
commit 059ad64cea
@@ -243,15 +243,22 @@ return core.Class.extend({
_register: function (do_update, tour, name) {
if (tour.ready) return $.when();
var tour_is_consumed = _.contains(this.consumed_tours, name);
return tour.wait_for.then((function () {
tour.current_step = parseInt(local_storage.getItem(get_step_key(name))) || 0;
tour.steps = _.filter(tour.steps, (function (step) {
return !step.edition || step.edition === this.edition;
}).bind(this));
if (tour_is_consumed || tour.current_step >= tour.steps.length) {
local_storage.removeItem(get_step_key(name));
tour.current_step = 0;
}
tour.ready = true;
if (do_update && (this.running_tour === name || (!this.running_tour && !tour.test && !_.contains(this.consumed_tours, name)))) {
if (do_update && (this.running_tour === name || (!this.running_tour && !tour.test && !tour_is_consumed))) {
this._to_next_step(name, 0);
this.update(name);
}