Skip to content
Permalink
Browse files

[FIX] im_livechat: fix the ajax loading on external website

Bug
===
The file "public_root.js" try to load "/web/webclient/locale/en_US" with ajax.loadJS
we do not have the address to the Odoo server, so we try to load the file locally
but this file might not exist on the website which is using the widget

Fix
===
Overwrite ``ajax.loadJS`` and ignore ajax loading
(also printing a warning message in the JS console)

Task #2081146

closes #39757

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
  • Loading branch information
std-odoo committed Nov 4, 2019
1 parent 738cefb commit 50f8508ca8569acc538a2af6a3c1162d39f834cd
@@ -0,0 +1,14 @@
odoo.define('web.ajax_external', function (require) {
"use strict";

var ajax = require('web.ajax');

/**
* This file should be used in the context of an external widget loading (e.g: live chat in a non-Odoo website)
* It overrides the 'loadJS' method that is supposed to load additional scripts, based on a relative URL (e.g: '/web/webclient/locale/en_US')
* As we're not in an Odoo website context, the calls will not work, and we avoid a 404 request.
*/
ajax.loadJS = function (url) {
console.warn('Tried to load the following script on an external website: ' + url);
};
});
@@ -133,6 +133,7 @@
<script type="text/javascript" src="/web/static/src/js/core/collections.js"/>
<script type="text/javascript" src="/web/static/src/js/core/translation.js"></script>
<script type="text/javascript" src="/web/static/src/js/core/ajax.js"></script>
<script type="text/javascript" src="/im_livechat/static/src/js/ajax_external.js"></script>
<script type="text/javascript" src="/web/static/src/js/core/time.js"></script>
<script type="text/javascript" src="/web/static/src/js/core/mixins.js"></script>
<script type="text/javascript" src="/web/static/src/js/core/service_mixins.js"></script>

0 comments on commit 50f8508

Please sign in to comment.
You can’t perform that action at this time.