From 8b9e854be4bfe3eda9a15368a864f7af606dee31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Thu, 15 Feb 2018 11:45:33 +0100 Subject: [PATCH] [FIX] im_livechat: livechat button not rely on JS services Revision of https://github.com/odoo/odoo/commit/02ec09cb1c3e2d7bc7968f40c18f2208d7f3f498 One of the purposes of the previous commit was to test discuss. There was an attempt to test im_livechat, but it has been aborted due to the possibility to use livechat on an external website. However, some bits remain from this attempt, such as LivechatButton becoming a JS service provider in order to use those services with the external lib. LivechatButton was not working for the following reasons: - ServiceProviderMixin.init was not called (so it couldn't load any service); - On website, there are two service providers (LivechatButton & websiteRootInstance). This fix ensures that LivechatButton does not rely on JS services, such as the bus_service. --- addons/im_livechat/static/src/js/im_livechat.js | 10 +++------- .../views/im_livechat_channel_templates.xml | 1 - addons/website_livechat/views/website_livechat.xml | 1 - 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js index e9d23227202..d652325d757 100644 --- a/addons/im_livechat/static/src/js/im_livechat.js +++ b/addons/im_livechat/static/src/js/im_livechat.js @@ -1,9 +1,9 @@ odoo.define('im_livechat.im_livechat', function (require) { "use strict"; +var bus = require('bus.bus').bus; var config = require('web.config'); var core = require('web.core'); -var ServiceProviderMixin = require('web.ServiceProviderMixin'); var session = require('web.session'); var time = require('web.time'); var utils = require('web.utils'); @@ -33,11 +33,7 @@ if (!_.contains(url_history, page)) { utils.set_cookie(LIVECHAT_COOKIE_HISTORY, JSON.stringify(url_history), 60*60*24); // 1 day cookie } -/** - * In order to handle services like ajax in the external lib, - * The parent of Livechat, LivechatButton, is set as a service provider - */ -var LivechatButton = Widget.extend(ServiceProviderMixin, { +var LivechatButton = Widget.extend({ className:"openerp o_livechat_button hidden-print", events: { @@ -56,7 +52,7 @@ var LivechatButton = Widget.extend(ServiceProviderMixin, { this.chat_window = null; this.messages = []; this.server_url = server_url; - this.busBus = this.call('bus_service', 'getBus'); + this.busBus = bus; }, willStart: function () { diff --git a/addons/im_livechat/views/im_livechat_channel_templates.xml b/addons/im_livechat/views/im_livechat_channel_templates.xml index ec25a417dca..3c13ab09fd8 100644 --- a/addons/im_livechat/views/im_livechat_channel_templates.xml +++ b/addons/im_livechat/views/im_livechat_channel_templates.xml @@ -142,7 +142,6 @@ - diff --git a/addons/website_livechat/views/website_livechat.xml b/addons/website_livechat/views/website_livechat.xml index 3a994c4e4ac..3a0caa340ba 100644 --- a/addons/website_livechat/views/website_livechat.xml +++ b/addons/website_livechat/views/website_livechat.xml @@ -9,7 +9,6 @@