[FIX] im_livechat: correct loader js code
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user