[IMP] Added feature in the rpc() method to be able to perform a call without triggering the loading messages.
bzr revid: nicolas.vanhoren@openerp.com-20121116094200-q4cby6jofcrk87hd
This commit is contained in:
parent
898bdf9e98
commit
76cce62c99
|
@ -952,7 +952,7 @@ instance.web.UserMenu = instance.web.Widget.extend({
|
|||
on_menu_settings: function() {
|
||||
var self = this;
|
||||
if (!this.getParent().has_uncommitted_changes()) {
|
||||
self.rpc("/web/action/load", { action_id: "base.action_res_users_my" }, function(result) {
|
||||
self.rpc("/web/action/load", { action_id: "base.action_res_users_my" }).done(function(result) {
|
||||
result.res_id = instance.session.uid;
|
||||
self.getParent().action_manager.do_action(result);
|
||||
});
|
||||
|
|
|
@ -774,10 +774,10 @@ instance.web.Widget = instance.web.Class.extend(instance.web.PropertiesMixin, {
|
|||
}
|
||||
return false;
|
||||
},
|
||||
rpc: function(url, data, success, error) {
|
||||
var def = $.Deferred().done(success).fail(error);
|
||||
rpc: function(url, data, options) {
|
||||
var def = $.Deferred();
|
||||
var self = this;
|
||||
instance.session.rpc(url, data).done(function() {
|
||||
instance.session.rpc(url, data, options).done(function() {
|
||||
if (!self.isDestroyed())
|
||||
def.resolve.apply(def, arguments);
|
||||
}).fail(function() {
|
||||
|
@ -1231,12 +1231,14 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, {
|
|||
*
|
||||
* @param {String} url RPC endpoint
|
||||
* @param {Object} params call parameters
|
||||
* @param {Object} options additional options for rpc call
|
||||
* @param {Function} success_callback function to execute on RPC call success
|
||||
* @param {Function} error_callback function to execute on RPC call failure
|
||||
* @returns {jQuery.Deferred} jquery-provided ajax deferred
|
||||
*/
|
||||
rpc: function(url, params) {
|
||||
rpc: function(url, params, options) {
|
||||
var self = this;
|
||||
options = options || {};
|
||||
// url can be an $.ajax option object
|
||||
if (_.isString(url)) {
|
||||
url = { url: url };
|
||||
|
@ -1251,10 +1253,12 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, {
|
|||
id: _.uniqueId('r')
|
||||
};
|
||||
var deferred = $.Deferred();
|
||||
this.trigger('request', url, payload);
|
||||
if (! options.shadow)
|
||||
this.trigger('request', url, payload);
|
||||
var request = this.rpc_function(url, payload).done(
|
||||
function (response, textStatus, jqXHR) {
|
||||
self.trigger('response', response);
|
||||
if (! options.shadow)
|
||||
self.trigger('response', response);
|
||||
if (!response.error) {
|
||||
if (url.url === '/web/session/eval_domain_and_context') {
|
||||
self.test_eval(params, response.result);
|
||||
|
@ -1268,7 +1272,8 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, {
|
|||
}
|
||||
).fail(
|
||||
function(jqXHR, textStatus, errorThrown) {
|
||||
self.trigger('response_failed', jqXHR);
|
||||
if (! options.shadow)
|
||||
self.trigger('response_failed', jqXHR);
|
||||
var error = {
|
||||
code: -32098,
|
||||
message: "XmlHttpRequestError " + errorThrown,
|
||||
|
|
|
@ -22,9 +22,9 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
|
|||
this.name = instance._session_id;
|
||||
this.qweb_mutex = new $.Mutex();
|
||||
},
|
||||
rpc: function(url, params) {
|
||||
rpc: function(url, params, options) {
|
||||
params.session_id = this.session_id;
|
||||
return this._super(url, params);
|
||||
return this._super(url, params, options);
|
||||
},
|
||||
/**
|
||||
* Setup a sessionm
|
||||
|
|
|
@ -278,9 +278,10 @@ instance.web.Model = instance.web.Class.extend({
|
|||
* @param {String} method name of the method to call
|
||||
* @param {Array} [args] positional arguments
|
||||
* @param {Object} [kwargs] keyword arguments
|
||||
* @param {Object} [options] additional options for the rpc() method
|
||||
* @returns {jQuery.Deferred<>} call result
|
||||
*/
|
||||
call: function (method, args, kwargs) {
|
||||
call: function (method, args, kwargs, options) {
|
||||
args = args || [];
|
||||
kwargs = kwargs || {};
|
||||
if (!_.isArray(args)) {
|
||||
|
@ -294,7 +295,7 @@ instance.web.Model = instance.web.Class.extend({
|
|||
method: method,
|
||||
args: args,
|
||||
kwargs: kwargs
|
||||
});
|
||||
}, options);
|
||||
},
|
||||
/**
|
||||
* Fetches a Query instance bound to this model, for searching
|
||||
|
|
Loading…
Reference in New Issue