', type='http', auth='none')
def livechat_lib(self, ext, **kwargs):
# _get_asset return the bundle html code (script and link list) but we want to use the attachment content
@@ -26,6 +29,17 @@ class LivechatController(http.Controller):
headers.append(('Content-Length', len(content_base64)))
return request.make_response(content_base64, headers)
+ @http.route('/im_livechat/load_templates', type='json', auth='none', cors="*")
+ def load_templates(self, **kwargs):
+ base_url = request.httprequest.base_url
+ templates = [
+ 'mail/static/src/xml/abstract_thread_window.xml',
+ 'mail/static/src/xml/discuss.xml',
+ 'mail/static/src/xml/thread.xml',
+ 'im_livechat/static/src/xml/im_livechat.xml',
+ ]
+ return [tools.file_open(tmpl, 'rb').read() for tmpl in templates]
+
@http.route('/im_livechat/support/
', type='http', auth='public')
def support_page(self, channel_id, **kwargs):
channel = request.env['im_livechat.channel'].sudo().browse(channel_id)
@@ -38,7 +52,7 @@ class LivechatController(http.Controller):
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}, headers=[('Content-Type', 'application/javascript')])
- @http.route('/im_livechat/init', type='json', auth="public")
+ @http.route('/im_livechat/init', type='json', auth="public", cors="*")
def livechat_init(self, channel_id):
LivechatChannel = request.env['im_livechat.channel']
available = len(LivechatChannel.browse(channel_id).get_available_users())
@@ -66,7 +80,7 @@ class LivechatController(http.Controller):
'rule': rule,
}
- @http.route('/im_livechat/get_session', type="json", auth='public')
+ @http.route('/im_livechat/get_session', type="json", auth='public', cors="*")
def get_session(self, channel_id, anonymous_name, **kwargs):
user_id = None
country_id = None
@@ -83,7 +97,7 @@ class LivechatController(http.Controller):
anonymous_name, country_id = _("%s (%s)") % (anonymous_name, country.name), country.id
return request.env["im_livechat.channel"].with_context(lang=False).get_mail_channel(channel_id, anonymous_name, user_id, country_id)
- @http.route('/im_livechat/feedback', type='json', auth='public')
+ @http.route('/im_livechat/feedback', type='json', auth='public', cors="*")
def feedback(self, uuid, rate, reason=None, **kwargs):
Channel = request.env['mail.channel']
Rating = request.env['rating.rating']
@@ -114,7 +128,7 @@ class LivechatController(http.Controller):
return rating.id
return False
- @http.route('/im_livechat/history', type="json", auth="public")
+ @http.route('/im_livechat/history', type="json", auth="public", cors="*")
def history_pages(self, pid, channel_uuid, page_history=None):
partner_ids = (pid, request.env.user.partner_id.id)
channel = request.env['mail.channel'].sudo().search([('uuid', '=', channel_uuid), ('channel_partner_ids', 'in', partner_ids)])
@@ -122,7 +136,7 @@ class LivechatController(http.Controller):
channel._send_history_message(pid, page_history)
return True
- @http.route('/im_livechat/notify_typing', type='json', auth='public')
+ @http.route('/im_livechat/notify_typing', type='json', auth='public', cors="*")
def notify_typing(self, uuid, is_typing):
""" Broadcast the typing notification of the website user to other channel members
:param uuid: (string) the UUID of the livechat channel
diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js
index f59a03e2040..964e9ef5d3e 100644
--- a/addons/im_livechat/static/src/js/im_livechat.js
+++ b/addons/im_livechat/static/src/js/im_livechat.js
@@ -190,15 +190,11 @@ var LivechatButton = Widget.extend({
* @private
*/
_loadQWebTemplate: function () {
- var xml_files = ['/mail/static/src/xml/abstract_thread_window.xml',
- '/mail/static/src/xml/thread.xml',
- '/im_livechat/static/src/xml/im_livechat.xml'];
- var defs = _.map(xml_files, function (tmpl) {
- return session.rpc('/web/proxy/load', { path: tmpl }).then(function (xml) {
- QWeb.add_template(xml);
+ return session.rpc('/im_livechat/load_templates').then(function (templates) {
+ _.each(templates, function (template) {
+ QWeb.add_template(template);
});
});
- return $.when.apply($, defs);
},
/**
* @private
diff --git a/addons/im_livechat/views/im_livechat_channel_templates.xml b/addons/im_livechat/views/im_livechat_channel_templates.xml
index 85861a185fa..d029ae32478 100644
--- a/addons/im_livechat/views/im_livechat_channel_templates.xml
+++ b/addons/im_livechat/views/im_livechat_channel_templates.xml
@@ -194,7 +194,7 @@
odoo.define('web.session', function (require) {
var Session = require('web.Session');
var modules = odoo._modules;
- return new Session(undefined, "", {modules:modules, use_cors: false});
+ return new Session(undefined, "", {modules:modules, use_cors: true});
});
diff --git a/addons/mail/controllers/bus.py b/addons/mail/controllers/bus.py
index c900604ab06..912aae3cacd 100644
--- a/addons/mail/controllers/bus.py
+++ b/addons/mail/controllers/bus.py
@@ -34,7 +34,7 @@ class MailChatController(BusController):
# --------------------------
# Anonymous routes (Common Methods)
# --------------------------
- @route('/mail/chat_post', type="json", auth="none")
+ @route('/mail/chat_post', type="json", auth="none", cors="*")
def mail_chat_post(self, uuid, message_content, **kwargs):
# find the author from the user session, which can be None
author_id = False # message_post accept 'False' author_id, but not 'None'
@@ -46,7 +46,7 @@ class MailChatController(BusController):
message = mail_channel.sudo().with_context(mail_create_nosubscribe=True).message_post(author_id=author_id, email_from=False, body=body, message_type='comment', subtype='mail.mt_comment')
return message and message.id or False
- @route(['/mail/chat_history'], type="json", auth="none")
+ @route(['/mail/chat_history'], type="json", auth="none", cors="*")
def mail_chat_history(self, uuid, last_id=False, limit=20):
channel = request.env["mail.channel"].sudo().search([('uuid', '=', uuid)], limit=1)
if not channel:
diff --git a/addons/mail/static/src/xml/activity.xml b/addons/mail/static/src/xml/activity.xml
index dafad00b008..217e1a39f5c 100644
--- a/addons/mail/static/src/xml/activity.xml
+++ b/addons/mail/static/src/xml/activity.xml
@@ -98,7 +98,6 @@
/web/binary/upload_attachment
-
diff --git a/addons/mail/static/src/xml/composer.xml b/addons/mail/static/src/xml/composer.xml
index b9de0194e93..f405617affa 100644
--- a/addons/mail/static/src/xml/composer.xml
+++ b/addons/mail/static/src/xml/composer.xml
@@ -37,7 +37,6 @@
-
diff --git a/addons/mail/static/src/xml/web_kanban_activity.xml b/addons/mail/static/src/xml/web_kanban_activity.xml
index 698091e9875..4d6c290f11f 100644
--- a/addons/mail/static/src/xml/web_kanban_activity.xml
+++ b/addons/mail/static/src/xml/web_kanban_activity.xml
@@ -92,7 +92,6 @@