From 100d604cb0ebd6aa3f57c9809c6771b0b4b72a07 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 6 Jan 2016 18:56:37 +0100 Subject: [PATCH] [FIX] im_livechat: correct loader js code --- addons/im_livechat/controllers/main.py | 3 ++- addons/im_livechat/models/im_livechat_channel.py | 2 +- addons/im_livechat/views/im_livechat_channel_templates.xml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/im_livechat/controllers/main.py b/addons/im_livechat/controllers/main.py index 43e547e2fb1..30ae212c8b2 100644 --- a/addons/im_livechat/controllers/main.py +++ b/addons/im_livechat/controllers/main.py @@ -30,7 +30,8 @@ class LivechatController(http.Controller): username = kwargs.get("username", _("Visitor")) channel = request.env['im_livechat.channel'].sudo().browse(channel_id) info = request.env['im_livechat.channel'].get_livechat_info(channel.id, username=username) - return request.render('im_livechat.loader', {'info': info, 'web_session_required': True}) if info['available'] else False + js = request.render('im_livechat.loader', {'info': info, 'web_session_required': True}) + return request.make_response(js, headers=[('Content-Type', 'application/javascript')]) @http.route('/im_livechat/init', type='json', auth="public") def livechat_init(self, channel_id): diff --git a/addons/im_livechat/models/im_livechat_channel.py b/addons/im_livechat/models/im_livechat_channel.py index e15d4212a43..ac894a2c7ab 100644 --- a/addons/im_livechat/models/im_livechat_channel.py +++ b/addons/im_livechat/models/im_livechat_channel.py @@ -195,7 +195,7 @@ class ImLivechatChannel(models.Model): @api.model def get_livechat_info(self, channel_id, username='Visitor'): info = {} - info['available'] = len(self.browse(channel_id).get_available_users()) + info['available'] = len(self.browse(channel_id).get_available_users()) > 0 if info['available']: info['server_url'] = self.env['ir.config_parameter'].get_param('web.base.url') info['options'] = self.sudo().get_channel_infos(channel_id) diff --git a/addons/im_livechat/views/im_livechat_channel_templates.xml b/addons/im_livechat/views/im_livechat_channel_templates.xml index d97df04989e..0efd2310a14 100644 --- a/addons/im_livechat/views/im_livechat_channel_templates.xml +++ b/addons/im_livechat/views/im_livechat_channel_templates.xml @@ -143,7 +143,6 @@ - document.addEventListener("DOMContentLoaded", function(event) { odoo.define('web.session', function (require) { @@ -154,6 +153,7 @@ odoo.define('im_livechat.livesupport', function (require) { + var im_livechat = require('im_livechat.im_livechat'); var button = new im_livechat.LivechatButton( $('body'), @@ -162,9 +162,9 @@ ); button.appendTo($('body')); window.livechat_button = button; + }); }); -