[MERGE] callback2deferred dataset.name_get
bzr revid: al@openerp.com-20120930150329-b3j0pmnf7gnxlxzj
This commit is contained in:
commit
1a369bfd3c
|
@ -636,8 +636,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
|
||||||
* @returns {$.Deferred}
|
* @returns {$.Deferred}
|
||||||
*/
|
*/
|
||||||
create: function(data) {
|
create: function(data) {
|
||||||
return this._model.call('create',
|
return this._model.call('create', [data], {context: this._model.context()})
|
||||||
[data], {context: this._model.context()})
|
|
||||||
.pipe(function (r) { return {result: r}; });
|
.pipe(function (r) { return {result: r}; });
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -718,10 +717,8 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
* @returns {$.Deferred}
|
* @returns {$.Deferred}
|
||||||
*/
|
*/
|
||||||
name_get: function(ids, callback) {
|
name_get: function(ids) {
|
||||||
return this._model.call('name_get',
|
return this._model.call('name_get', [ids], {context: this._model.context()});
|
||||||
[ids], {context: this._model.context()})
|
|
||||||
.then(callback);
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -746,8 +743,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
|
||||||
* @param callback
|
* @param callback
|
||||||
*/
|
*/
|
||||||
name_create: function(name) {
|
name_create: function(name) {
|
||||||
return this._model.call('name_create',
|
return this._model.call('name_create', [name], {context: this._model.context()});
|
||||||
[name], {context: this._model.context()});
|
|
||||||
},
|
},
|
||||||
exec_workflow: function (id, signal) {
|
exec_workflow: function (id, signal) {
|
||||||
return this._model.exec_workflow(id, signal)
|
return this._model.exec_workflow(id, signal)
|
||||||
|
|
|
@ -1499,7 +1499,7 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({
|
||||||
// to handle this as if it were a single value.
|
// to handle this as if it were a single value.
|
||||||
value = value[0];
|
value = value[0];
|
||||||
}
|
}
|
||||||
return this.model.call('name_get', [value], {}).pipe(function (names) {
|
return this.model.call('name_get', [value]).pipe(function (names) {
|
||||||
if (_(names).isEmpty()) { return null; }
|
if (_(names).isEmpty()) { return null; }
|
||||||
return facet_from(self, names[0]);
|
return facet_from(self, names[0]);
|
||||||
})
|
})
|
||||||
|
|
|
@ -3040,7 +3040,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
||||||
}
|
}
|
||||||
if (! no_recurse) {
|
if (! no_recurse) {
|
||||||
var dataset = new instance.web.DataSetStatic(this, this.field.relation, self.build_context());
|
var dataset = new instance.web.DataSetStatic(this, this.field.relation, self.build_context());
|
||||||
dataset.name_get([self.get("value")], function(data) {
|
dataset.name_get([self.get("value")]).then(function(data) {
|
||||||
self.display_value["" + self.get("value")] = data[0][1];
|
self.display_value["" + self.get("value")] = data[0][1];
|
||||||
self.render_value(true);
|
self.render_value(true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -989,7 +989,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
|
||||||
// to get a correctly displayable value in the field
|
// to get a correctly displayable value in the field
|
||||||
var model = ref_match[1],
|
var model = ref_match[1],
|
||||||
id = parseInt(ref_match[2], 10);
|
id = parseInt(ref_match[2], 10);
|
||||||
new instance.web.DataSet(this.view, model).name_get([id], function(names) {
|
new instance.web.DataSet(this.view, model).name_get([id]).then(function(names) {
|
||||||
if (!names.length) { return; }
|
if (!names.length) { return; }
|
||||||
record.set(column.id, names[0][1]);
|
record.set(column.id, names[0][1]);
|
||||||
});
|
});
|
||||||
|
@ -1005,7 +1005,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
|
||||||
// and let the various registered events handle refreshing the
|
// and let the various registered events handle refreshing the
|
||||||
// row
|
// row
|
||||||
new instance.web.DataSet(this.view, column.relation)
|
new instance.web.DataSet(this.view, column.relation)
|
||||||
.name_get([value], function (names) {
|
.name_get([value]).then(function (names) {
|
||||||
if (!names.length) { return; }
|
if (!names.length) { return; }
|
||||||
record.set(column.id, names[0]);
|
record.set(column.id, names[0]);
|
||||||
});
|
});
|
||||||
|
|
|
@ -91,7 +91,7 @@ $(document).ready(function () {
|
||||||
ok(_.isEmpty(r.kwargs));
|
ok(_.isEmpty(r.kwargs));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
t.test('name_get', function (openerp) {
|
t.test('name_get').then(function (openerp) {
|
||||||
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
||||||
t.expect(ds.name_get([1, 2], null), function (r) {
|
t.expect(ds.name_get([1, 2], null), function (r) {
|
||||||
strictEqual(r.method, 'name_get');
|
strictEqual(r.method, 'name_get');
|
||||||
|
|
Loading…
Reference in New Issue