From 6ba709a81236498b15656a04c8136cbcf7e1d6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Mottet=20=28oms=29?= Date: Tue, 18 May 2021 14:37:37 +0000 Subject: [PATCH] [FIX] website: correctly activate tour for each website MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Creating a website through the configurator activated the configurator tour. This tour was active for every websites even the ones not created using the configurator. Theme tours were overridden by the configurator tour when they should have been the active tour for website not created using the configurator. Now the configurator tour is an asset specific to each website. This asset is deactivated by default and activated for a website only if it is created using the configurator. - Some actions of the website tour were also visible when we were not in edit mode. extra_trigger has been added on these actions to ensure they are visible only in edit mode. task-2518565 closes odoo/odoo#72827 X-original-commit: 5799410ec257fc7f756722579d3d0141b0ce7de4 Signed-off-by: Jérémy Kersten (jke) --- addons/website/data/ir_asset.xml | 3 ++- addons/website/models/website.py | 4 ++-- addons/website/static/src/js/tours/configurator_tour.js | 2 +- addons/website/static/src/js/tours/tour_utils.js | 4 ++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/website/data/ir_asset.xml b/addons/website/data/ir_asset.xml index 1eb9e832840..7ae97f1475d 100644 --- a/addons/website/data/ir_asset.xml +++ b/addons/website/data/ir_asset.xml @@ -25,7 +25,8 @@ - website.configurator_tour + website.configurator_tour + Website Configurator Tour website.assets_editor website/static/src/js/tours/configurator_tour.js diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 1a948b398cc..df51c95e313 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -418,8 +418,8 @@ class Website(models.Model): website.configurator_done = True # Enable tour - tour_asset_id = self.env['ir.asset']._get_related_assets([('name', '=', 'website.configurator_tour')]) - tour_asset_id.sudo().write({'active': True}) + tour_asset_id = self.env.ref('website.configurator_tour') + tour_asset_id.copy({'key': tour_asset_id.key, 'website_id': website.id, 'active': True}) # logo was generated as base64 url logo = kwargs.get('logo') diff --git a/addons/website/static/src/js/tours/configurator_tour.js b/addons/website/static/src/js/tours/configurator_tour.js index 22b554d3695..16e44031fb7 100644 --- a/addons/website/static/src/js/tours/configurator_tour.js +++ b/addons/website/static/src/js/tours/configurator_tour.js @@ -1,4 +1,4 @@ -odoo.define("website.configurator.tour", function (require) { +odoo.define("website.configurator_tour", function (require) { "use strict"; const wTourUtils = require("website.tour_utils"); diff --git a/addons/website/static/src/js/tours/tour_utils.js b/addons/website/static/src/js/tours/tour_utils.js index ddf5089442c..351e1d12ecf 100644 --- a/addons/website/static/src/js/tours/tour_utils.js +++ b/addons/website/static/src/js/tours/tour_utils.js @@ -55,6 +55,7 @@ function changeColumnSize(position = "right") { function changeIcon(snippet, index = 0, position = "bottom") { return { trigger: `#wrapwrap .${snippet.id} i:eq(${index})`, + extra_trigger: "body.editor_enable", content: _t("Double click on an icon to change it with one of your choice."), position: position, run: "dblclick", @@ -64,6 +65,7 @@ function changeIcon(snippet, index = 0, position = "bottom") { function changeImage(snippet, position = "bottom") { return { trigger: snippet.id ? `#wrapwrap .${snippet.id} img` : snippet, + extra_trigger: "body.editor_enable", content: _t("Double click on an image to change it with one of your choice."), position: position, run: "dblclick", @@ -130,6 +132,7 @@ function clickOnEdit(position = "bottom") { function clickOnSnippet(snippet, position = "bottom") { return { trigger: snippet.id ? `#wrapwrap .${snippet.id}` : snippet, + extra_trigger: "body.editor_enable", content: _t("Click on a snippet to access its options menu."), position: position, run: "click", @@ -158,6 +161,7 @@ function clickOnSave(position = "bottom") { function clickOnText(snippet, element, position = "bottom") { return { trigger: snippet.id ? `#wrapwrap .${snippet.id} ${element}` : snippet, + extra_trigger: "body.editor_enable", content: _t("Click on a text to start editing it."), position: position, run: "text",