Skip to content

Commit

Permalink
[FIX] im_livechat: fix the ajax loading on external website
Browse files Browse the repository at this point in the history
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 50f8508
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions addons/im_livechat/static/src/js/ajax_external.js
@@ -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);
};
});
1 change: 1 addition & 0 deletions addons/im_livechat/views/im_livechat_channel_templates.xml
Expand Up @@ -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>
Expand Down

0 comments on commit 50f8508

Please sign in to comment.