[MERGE] callback2deferred session.rpc
bzr revid: al@openerp.com-20121006163238-7ni5r324c0yqi5a0
This commit is contained in:
commit
55bcd978af
|
@ -392,7 +392,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
|
||||||
do_create: function(form) {
|
do_create: function(form) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var fields = $(form).serializeArray();
|
var fields = $(form).serializeArray();
|
||||||
self.rpc("/web/database/create", {'fields': fields}, function(result) {
|
self.rpc("/web/database/create", {'fields': fields}).then(function(result) {
|
||||||
var form_obj = self.to_object(fields);
|
var form_obj = self.to_object(fields);
|
||||||
var client_action = {
|
var client_action = {
|
||||||
type: 'ir.actions.client',
|
type: 'ir.actions.client',
|
||||||
|
@ -418,7 +418,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
|
||||||
if (!db || !confirm("Do you really want to delete the database: " + db + " ?")) {
|
if (!db || !confirm("Do you really want to delete the database: " + db + " ?")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.rpc("/web/database/drop", {'fields': fields}, function(result) {
|
self.rpc("/web/database/drop", {'fields': fields}).then(function(result) {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
self.display_error(result);
|
self.display_error(result);
|
||||||
return;
|
return;
|
||||||
|
@ -481,7 +481,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
|
||||||
var self = this;
|
var self = this;
|
||||||
self.rpc("/web/database/change_password", {
|
self.rpc("/web/database/change_password", {
|
||||||
'fields': $(form).serializeArray()
|
'fields': $(form).serializeArray()
|
||||||
}, function(result) {
|
}).then(function(result) {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
self.display_error(result);
|
self.display_error(result);
|
||||||
return;
|
return;
|
||||||
|
@ -660,7 +660,7 @@ instance.web.ChangePassword = instance.web.Widget.extend({
|
||||||
submitHandler: function (form) {
|
submitHandler: function (form) {
|
||||||
self.rpc("/web/session/change_password",{
|
self.rpc("/web/session/change_password",{
|
||||||
'fields': $(form).serializeArray()
|
'fields': $(form).serializeArray()
|
||||||
}, function(result) {
|
}).then(function(result) {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
self.display_error(result);
|
self.display_error(result);
|
||||||
return;
|
return;
|
||||||
|
@ -1165,7 +1165,7 @@ instance.web.EmbeddedClient = instance.web.Client.extend({
|
||||||
var self = this;
|
var self = this;
|
||||||
return $.when(this._super()).pipe(function() {
|
return $.when(this._super()).pipe(function() {
|
||||||
return instance.session.session_authenticate(self.dbname, self.login, self.key, true).pipe(function() {
|
return instance.session.session_authenticate(self.dbname, self.login, self.key, true).pipe(function() {
|
||||||
return self.rpc("/web/action/load", { action_id: self.action_id }, function(result) {
|
return self.rpc("/web/action/load", { action_id: self.action_id }).then(function(result) {
|
||||||
var action = result;
|
var action = result;
|
||||||
action.flags = _.extend({
|
action.flags = _.extend({
|
||||||
//views_switcher : false,
|
//views_switcher : false,
|
||||||
|
|
|
@ -842,7 +842,7 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, {
|
||||||
rpc: function(url, data, success, error) {
|
rpc: function(url, data, success, error) {
|
||||||
var def = $.Deferred().then(success, error);
|
var def = $.Deferred().then(success, error);
|
||||||
var self = this;
|
var self = this;
|
||||||
instance.session.rpc(url, data). then(function() {
|
instance.session.rpc(url, data).then(function() {
|
||||||
if (!self.isDestroyed())
|
if (!self.isDestroyed())
|
||||||
def.resolve.apply(def, arguments);
|
def.resolve.apply(def, arguments);
|
||||||
}, function() {
|
}, function() {
|
||||||
|
@ -1300,7 +1300,7 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
|
||||||
* @param {Function} error_callback function to execute on RPC call failure
|
* @param {Function} error_callback function to execute on RPC call failure
|
||||||
* @returns {jQuery.Deferred} jquery-provided ajax deferred
|
* @returns {jQuery.Deferred} jquery-provided ajax deferred
|
||||||
*/
|
*/
|
||||||
rpc: function(url, params, success_callback, error_callback) {
|
rpc: function(url, params) {
|
||||||
var self = this;
|
var self = this;
|
||||||
// url can be an $.ajax option object
|
// url can be an $.ajax option object
|
||||||
if (_.isString(url)) {
|
if (_.isString(url)) {
|
||||||
|
@ -1317,8 +1317,6 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
|
||||||
};
|
};
|
||||||
var deferred = $.Deferred();
|
var deferred = $.Deferred();
|
||||||
this.trigger('request', url, payload);
|
this.trigger('request', url, payload);
|
||||||
var aborter = params.aborter;
|
|
||||||
delete params.aborter;
|
|
||||||
var request = this.rpc_function(url, payload).then(
|
var request = this.rpc_function(url, payload).then(
|
||||||
function (response, textStatus, jqXHR) {
|
function (response, textStatus, jqXHR) {
|
||||||
self.trigger('response', response);
|
self.trigger('response', response);
|
||||||
|
@ -1342,16 +1340,6 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
|
||||||
};
|
};
|
||||||
deferred.reject(error, $.Event());
|
deferred.reject(error, $.Event());
|
||||||
});
|
});
|
||||||
if (aborter) {
|
|
||||||
aborter.abort_last = function () {
|
|
||||||
if (!(request.isResolved() || request.isRejected())) {
|
|
||||||
deferred.fail(function (error, event) {
|
|
||||||
event.preventDefault();
|
|
||||||
});
|
|
||||||
request.abort();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// Allow deferred user to disable on_rpc_error in fail
|
// Allow deferred user to disable on_rpc_error in fail
|
||||||
deferred.fail(function() {
|
deferred.fail(function() {
|
||||||
deferred.fail(function(error, event) {
|
deferred.fail(function(error, event) {
|
||||||
|
@ -1359,7 +1347,7 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
|
||||||
self.on_rpc_error(error, event);
|
self.on_rpc_error(error, event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).then(success_callback, error_callback).promise();
|
});
|
||||||
return deferred;
|
return deferred;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,9 +19,9 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
|
||||||
this.name = instance._session_id;
|
this.name = instance._session_id;
|
||||||
this.qweb_mutex = new $.Mutex();
|
this.qweb_mutex = new $.Mutex();
|
||||||
},
|
},
|
||||||
rpc: function(url, params, success_callback, error_callback) {
|
rpc: function(url, params) {
|
||||||
params.session_id = this.session_id;
|
params.session_id = this.session_id;
|
||||||
return this._super(url, params, success_callback, error_callback);
|
return this._super(url, params);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Setup a sessionm
|
* Setup a sessionm
|
||||||
|
|
|
@ -51,7 +51,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
|
||||||
self.rpc("/web/export/get_fields", {
|
self.rpc("/web/export/get_fields", {
|
||||||
model: self.dataset.model,
|
model: self.dataset.model,
|
||||||
import_compat: Boolean(import_comp)
|
import_compat: Boolean(import_comp)
|
||||||
}, function (records) {
|
}).then(function (records) {
|
||||||
got_fields.resolve();
|
got_fields.resolve();
|
||||||
self.on_show_data(records);
|
self.on_show_data(records);
|
||||||
});
|
});
|
||||||
|
@ -59,7 +59,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
|
||||||
|
|
||||||
return $.when(
|
return $.when(
|
||||||
got_fields,
|
got_fields,
|
||||||
this.rpc('/web/export/formats', {}, this.do_setup_export_formats),
|
this.rpc('/web/export/formats', {}).then(this.do_setup_export_formats),
|
||||||
this.show_exports_list());
|
this.show_exports_list());
|
||||||
},
|
},
|
||||||
do_setup_export_formats: function (formats) {
|
do_setup_export_formats: function (formats) {
|
||||||
|
@ -93,7 +93,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
|
||||||
self.$el.find('#fields_list option').remove();
|
self.$el.find('#fields_list option').remove();
|
||||||
var export_id = self.$el.find('#saved_export_list option:selected').val();
|
var export_id = self.$el.find('#saved_export_list option:selected').val();
|
||||||
if (export_id) {
|
if (export_id) {
|
||||||
self.rpc('/web/export/namelist', {'model': self.dataset.model, export_id: parseInt(export_id)}, self.do_load_export_field);
|
self.rpc('/web/export/namelist', {'model': self.dataset.model, export_id: parseInt(export_id)}).then(self.do_load_export_field);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
self.$el.find('#delete_export_list').click(function() {
|
self.$el.find('#delete_export_list').click(function() {
|
||||||
|
@ -183,7 +183,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
|
||||||
import_compat: Boolean(import_comp),
|
import_compat: Boolean(import_comp),
|
||||||
parent_field_type : record['field_type'],
|
parent_field_type : record['field_type'],
|
||||||
exclude: exclude_fields
|
exclude: exclude_fields
|
||||||
}, function(results) {
|
}).then(function(results) {
|
||||||
record.loaded = true;
|
record.loaded = true;
|
||||||
self.on_show_data(results, record.id);
|
self.on_show_data(results, record.id);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1693,7 +1693,7 @@ instance.web.search.Advanced = instance.web.search.Input.extend({
|
||||||
});
|
});
|
||||||
return $.when(
|
return $.when(
|
||||||
this._super(),
|
this._super(),
|
||||||
this.rpc("/web/searchview/fields_get", {model: this.view.model}, function(data) {
|
this.rpc("/web/searchview/fields_get", {model: this.view.model}).then(function(data) {
|
||||||
self.fields = _.extend({
|
self.fields = _.extend({
|
||||||
id: { string: 'ID', type: 'id' }
|
id: { string: 'ID', type: 'id' }
|
||||||
}, data.fields);
|
}, data.fields);
|
||||||
|
|
|
@ -4489,7 +4489,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
|
||||||
self.rpc('/web/session/eval_domain_and_context', {
|
self.rpc('/web/session/eval_domain_and_context', {
|
||||||
domains: [],
|
domains: [],
|
||||||
contexts: [this.context]
|
contexts: [this.context]
|
||||||
}, function (results) {
|
}).then(function (results) {
|
||||||
var search_defaults = {};
|
var search_defaults = {};
|
||||||
_.each(results.context, function (value_, key) {
|
_.each(results.context, function (value_, key) {
|
||||||
var match = /^search_default_(.*)$/.exec(key);
|
var match = /^search_default_(.*)$/.exec(key);
|
||||||
|
@ -4557,7 +4557,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
|
||||||
domains: domains || [],
|
domains: domains || [],
|
||||||
contexts: contexts || [],
|
contexts: contexts || [],
|
||||||
group_by_seq: groupbys || []
|
group_by_seq: groupbys || []
|
||||||
}, function (results) {
|
}).then(function (results) {
|
||||||
self.view_list.do_search(results.domain, results.context, results.group_by);
|
self.view_list.do_search(results.domain, results.context, results.group_by);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -482,7 +482,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||||
view_type: "tree",
|
view_type: "tree",
|
||||||
context: this.dataset.get_context(context),
|
context: this.dataset.get_context(context),
|
||||||
toolbar: !!this.options.$sidebar
|
toolbar: !!this.options.$sidebar
|
||||||
}, callback);
|
}).then(callback);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,7 +45,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
|
||||||
view_type: "tree",
|
view_type: "tree",
|
||||||
toolbar: this.view_manager ? !!this.view_manager.sidebar : false,
|
toolbar: this.view_manager ? !!this.view_manager.sidebar : false,
|
||||||
context: this.dataset.get_context()
|
context: this.dataset.get_context()
|
||||||
}, this.on_loaded);
|
}).then(this.on_loaded);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Returns the list of fields needed to correctly read objects.
|
* Returns the list of fields needed to correctly read objects.
|
||||||
|
|
|
@ -654,7 +654,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
|
||||||
domains: [this.action.domain || []].concat(domains || []),
|
domains: [this.action.domain || []].concat(domains || []),
|
||||||
contexts: [action_context].concat(contexts || []),
|
contexts: [action_context].concat(contexts || []),
|
||||||
group_by_seq: groupbys || []
|
group_by_seq: groupbys || []
|
||||||
}, function (results) {
|
}).then(function (results) {
|
||||||
self.dataset._model = new instance.web.Model(
|
self.dataset._model = new instance.web.Model(
|
||||||
self.dataset.model, results.context, results.domain);
|
self.dataset.model, results.context, results.domain);
|
||||||
var groupby = results.group_by.length
|
var groupby = results.group_by.length
|
||||||
|
@ -1058,7 +1058,7 @@ instance.web.Sidebar = instance.web.Widget.extend({
|
||||||
self.rpc("/web/action/load", {
|
self.rpc("/web/action/load", {
|
||||||
action_id: item.action.id,
|
action_id: item.action.id,
|
||||||
context: additional_context
|
context: additional_context
|
||||||
}, function(result) {
|
}).then(function(result) {
|
||||||
result.result.context = _.extend(result.result.context || {},
|
result.result.context = _.extend(result.result.context || {},
|
||||||
additional_context);
|
additional_context);
|
||||||
result.result.flags = result.result.flags || {};
|
result.result.flags = result.result.flags || {};
|
||||||
|
@ -1237,7 +1237,7 @@ instance.web.View = instance.web.Widget.extend({
|
||||||
args.push(context);
|
args.push(context);
|
||||||
return dataset.call_button(action_data.name, args).then(handler);
|
return dataset.call_button(action_data.name, args).then(handler);
|
||||||
} else if (action_data.type=="action") {
|
} else if (action_data.type=="action") {
|
||||||
return this.rpc('/web/action/load', { action_id: action_data.name, context: context, do_not_eval: true}, handler);
|
return this.rpc('/web/action/load', { action_id: action_data.name, context: context, do_not_eval: true}).then(handler);
|
||||||
} else {
|
} else {
|
||||||
return dataset.exec_workflow(record_id, action_data.name).then(handler);
|
return dataset.exec_workflow(record_id, action_data.name).then(handler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
this._super();
|
this._super();
|
||||||
return this.rpc("/web/view/load", {"model": this.model, "view_id": this.view_id, "view_type":"calendar", 'toolbar': false}, this.on_loaded);
|
return this.rpc("/web/view/load", {"model": this.model, "view_id": this.view_id, "view_type":"calendar", 'toolbar': false}).then(this.on_loaded);
|
||||||
},
|
},
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
scheduler.clearAll();
|
scheduler.clearAll();
|
||||||
|
|
|
@ -105,8 +105,7 @@ instance.web.DiagramView = instance.web.View.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
this.rpc(
|
this.rpc(
|
||||||
'/web_diagram/diagram/get_diagram_info',params,
|
'/web_diagram/diagram/get_diagram_info',params).then(function(result) {
|
||||||
function(result) {
|
|
||||||
self.draw_diagram(result);
|
self.draw_diagram(result);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue