diff options
| author | Christophe Simonis <chs@odoo.com> | 2016-01-06 18:56:37 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2016-01-07 18:16:20 +0100 |
| commit | 100d604cb0ebd6aa3f57c9809c6771b0b4b72a07 (patch) | |
| tree | c209ee020b0882e6cc5ba0643b9870f1250b63ec /addons | |
| parent | 61cf01b7a8d9bedb577af0cf64f20bbeeb8c031c (diff) | |
[FIX] im_livechat: correct loader js code
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/im_livechat/controllers/main.py | 3 | ||||
| -rw-r--r-- | addons/im_livechat/models/im_livechat_channel.py | 2 | ||||
| -rw-r--r-- | 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 @@ <t t-set="info" t-value="request.env['im_livechat.channel'].get_livechat_info(channel)"/> </t> - <t t-if="info['available']" t-translation="off"> document.addEventListener("DOMContentLoaded", function(event) { <t t-if="web_session_required"> odoo.define('web.session', function (require) { @@ -154,6 +153,7 @@ </t> odoo.define('im_livechat.livesupport', function (require) { + <t t-if="info['available']" t-translation="off"> 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; + </t> }); }); - </t> </template> |
