diff --git a/addons/web_tour/assets.xml b/addons/web_tour/assets.xml index 769cda70721..8dd7749e03c 100644 --- a/addons/web_tour/assets.xml +++ b/addons/web_tour/assets.xml @@ -10,5 +10,11 @@ + + diff --git a/addons/web_tour/models/tour.py b/addons/web_tour/models/tour.py index 546bf020451..ccf6968fd63 100644 --- a/addons/web_tour/models/tour.py +++ b/addons/web_tour/models/tour.py @@ -14,10 +14,11 @@ class Tour(models.Model): user_id = fields.Many2one('res.users', string='Consumed by') @api.model - def consume(self, name): - """ Sets tour 'name' as consumed for the current user, meaning that - this tour won't be active anymore for that user """ - self.create({'name': name, 'user_id': self.env.uid}) + def consume(self, tour_names): + """ Sets given tours as consumed, meaning that + these tours won't be active anymore for that user """ + for name in tour_names: + self.create({'name': name, 'user_id': self.env.uid}) @api.model def get_consumed_tours(self): diff --git a/addons/web_tour/static/src/js/debug_manager.js b/addons/web_tour/static/src/js/debug_manager.js new file mode 100644 index 00000000000..3e23207462c --- /dev/null +++ b/addons/web_tour/static/src/js/debug_manager.js @@ -0,0 +1,28 @@ +odoo.define('web_tour.DebugManager', function (require) { +"use strict"; + +var DebugManager = require('web.DebugManager'); +var Model = require('web.Model'); + +var tour = require('web_tour.tour'); + +function get_active_tours () { + return _.difference(_.keys(tour.tours), tour.consumed_tours); +} + +DebugManager.include({ + start: function () { + this.consume_tours_enabled = get_active_tours().length > 0; + return this._super.apply(this, arguments); + }, + consume_tours: function () { + var active_tours = get_active_tours(); + if (active_tours.length > 0) { // tours might have been consumed meanwhile + new Model('web_tour.tour').call('consume', [active_tours]).then(function () { + window.location.reload(); + }); + } + }, +}); + +}); diff --git a/addons/web_tour/static/src/js/tour_manager.js b/addons/web_tour/static/src/js/tour_manager.js index 41341ee3d4a..a250274d45f 100644 --- a/addons/web_tour/static/src/js/tour_manager.js +++ b/addons/web_tour/static/src/js/tour_manager.js @@ -173,7 +173,9 @@ return core.Class.extend({ this.running_tour = undefined; clearTimeout(this.running_tour_timeout); } else { - this.TourModel.call('consume', [tour_name]); + this.TourModel.call('consume', [[tour_name]]).then((function () { + this.consumed_tours.push(tour_name); + }).bind(this)); } }, _set_running_tour_timeout: function(tour_name, step) { diff --git a/addons/web_tour/static/src/xml/debug_manager.xml b/addons/web_tour/static/src/xml/debug_manager.xml new file mode 100644 index 00000000000..d11aa2d0763 --- /dev/null +++ b/addons/web_tour/static/src/xml/debug_manager.xml @@ -0,0 +1,12 @@ + + + + + +
  • + Consume Tours +
  • +
    +
    + +