[MERGE] callback2deferred dataset.call
bzr revid: al@openerp.com-20121006162030-s5moj83dzegxlron
This commit is contained in:
commit
ef56fc10d0
|
@ -586,26 +586,8 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
|
|||
* @param {Function} error_callback
|
||||
* @returns {$.Deferred}
|
||||
*/
|
||||
call: function (method, args, callback, error_callback) {
|
||||
return this._model.call(method, args).then(callback, error_callback);
|
||||
},
|
||||
/**
|
||||
* Calls an arbitrary method, with more crazy
|
||||
*
|
||||
* @param {String} method
|
||||
* @param {Array} [args]
|
||||
* @param {Number} [domain_index] index of a domain to evaluate in the args array
|
||||
* @param {Number} [context_index] index of a context to evaluate in the args array
|
||||
* @returns {$.Deferred}
|
||||
*/
|
||||
call_and_eval: function (method, args, domain_index, context_index) {
|
||||
return instance.session.rpc('/web/dataset/call', {
|
||||
model: this.model,
|
||||
method: method,
|
||||
domain_id: domain_index == undefined ? null : domain_index,
|
||||
context_id: context_index == undefined ? null : context_index,
|
||||
args: args || []
|
||||
});
|
||||
call: function (method, args) {
|
||||
return this._model.call(method, args);
|
||||
},
|
||||
/**
|
||||
* Calls a button method, usually returning some sort of action
|
||||
|
|
|
@ -813,13 +813,11 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
|
|||
});
|
||||
break;
|
||||
case 'fields':
|
||||
this.dataset.call_and_eval(
|
||||
'fields_get', [false, {}], null, 1).then(function (fields) {
|
||||
this.dataset.call('fields_get', [false, {}]).then(function (fields) {
|
||||
var $root = $('<dl>');
|
||||
_(fields).each(function (attributes, name) {
|
||||
$root.append($('<dt>').append($('<h4>').text(name)));
|
||||
var $attrs = $('<dl>').appendTo(
|
||||
$('<dd>').appendTo($root));
|
||||
var $attrs = $('<dl>').appendTo($('<dd>').appendTo($root));
|
||||
_(attributes).each(function (def, name) {
|
||||
if (def instanceof Object) {
|
||||
def = JSON.stringify(def);
|
||||
|
|
|
@ -82,14 +82,14 @@ $(document).ready(function () {
|
|||
});
|
||||
t.test('call', function (openerp) {
|
||||
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
||||
t.expect(ds.call('frob', ['a', 'b', 42]), function (r) {
|
||||
t.expect(ds.call('frob', ['a', 'b', 42]).then(function (r) {
|
||||
strictEqual(r.method, 'frob');
|
||||
|
||||
strictEqual(r.args.length, 3);
|
||||
deepEqual(r.args, ['a', 'b', 42]);
|
||||
|
||||
ok(_.isEmpty(r.kwargs));
|
||||
});
|
||||
}));
|
||||
});
|
||||
t.test('name_get').then(function (openerp) {
|
||||
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
||||
|
|
|
@ -136,7 +136,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
|
|||
var field_dataset = new instance.web.DataSetSearch(this, this.model, null, null);
|
||||
var model_dataset = new instance.web.DataSetSearch(this, 'ir.model', null, null);
|
||||
var view_string = "", field_name = false, self = this;
|
||||
field_dataset.call( 'fields_get', [], function(fields) {
|
||||
field_dataset.call( 'fields_get', []).then(function(fields) {
|
||||
_.each(['name', 'x_name'], function(value) {
|
||||
if (_.include(_.keys(fields), value)) {
|
||||
field_name = value;
|
||||
|
@ -539,7 +539,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
|
|||
var value = _.has(_CHILDREN, element) ? element : _.str.include(html_tag, element)?"html_tag":false;
|
||||
property_to_check.push(value);
|
||||
});
|
||||
field_dataset.call( 'fields_get', [], function(result) {
|
||||
field_dataset.call( 'fields_get', []).then(function(result) {
|
||||
var fields = _.keys(result);
|
||||
fields.push(" "),fields.sort();
|
||||
self.on_add_node(property_to_check, fields);
|
||||
|
|
Loading…
Reference in New Issue