diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 7efd673f124..3d66c4f4ccf 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -361,7 +361,8 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. this.protocol = (protocol == undefined) ? location.protocol : protocol; this.prefix = this.protocol + '//' + this.host; openerp.web.qweb.default_dict['_s'] = this.prefix - this.rpc_mode = (host == location.host) ? "json" : "jsonp"; + this.rpc_mode = (this.host == location.host) ? "json" : "jsonp"; + this.rpc_function = (this.host == location.host) ? this.rpc_json : this.rpc_jsonp; this.debug = (window.location.search.indexOf('?debug') !== -1); this.session_id = false; this.uid = false; @@ -403,12 +404,11 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. jsonrpc: '2.0', method: 'call', params: params, - id: _.uniqueId('oe-') + id: _.uniqueId('r') }; - // Call using the rpc_mode var deferred = $.Deferred(); this.on_rpc_request(); - this.rpc_json(url, payload).then( + this.rpc_function(url, payload).then( function (response, textStatus, jqXHR) { self.on_rpc_response(); if (!response.error) { @@ -462,32 +462,35 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. }, rpc_jsonp: function(url, payload) { var self = this; + // extracted from payload to set on the url + var data = { + session_id: this.session_id, + id: payload.id, + }; + url.url = this.get_url(url.url); var ajax = _.extend({ type: "GET", dataType: 'jsonp', jsonp: 'jsonp', cache: false, - data: { - session_id: this.session_id, - id: payload.id, - } + data: data }, url); var payload_str = JSON.stringify(payload); var payload_url = $.param({r:payload_str}); if(playload_url.length < 2000) { - // Direct json request + // Direct jsonp request ajax.data.r = payload_str; return $.ajax(ajax); } else { - // Indirect json request - var ifid = _.uniqueId('oe_rpc_iframe_'); + // Indirect jsonp request + var ifid = _.uniqueId('oe_rpc_iframe'); var display = options.openerp.debug ? 'block' : 'none'; var $iframe = $(_.str.sprintf("", ifid, ifid, display)); var $form = $('