[IMP]remove callback from name_get function and improve related code.

bzr revid: vme@tinyerp.com-20120928065341-uiu3nf7seu5sps53
This commit is contained in:
Vidhin Mehta (OpenERP)
2012-09-28 12:23:41 +05:30
parent 6d692fac36
commit b4c8143480
5 changed files with 7 additions and 8 deletions
+2 -3
View File
@@ -719,10 +719,9 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
* @param {Function} callback
* @returns {$.Deferred}
*/
name_get: function(ids, callback) {
name_get: function(ids) {
return this._model.call('name_get',
[ids], {context: this._model.context()})
.then(callback);
[ids], {context: this._model.context()});
},
/**
*
+1 -1
View File
@@ -1502,7 +1502,7 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({
// to handle this as if it were a single value.
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; }
return facet_from(self, names[0]);
})
+1 -1
View File
@@ -3004,7 +3004,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
}
if (! no_recurse) {
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.render_value(true);
});
+2 -2
View File
@@ -989,7 +989,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
// to get a correctly displayable value in the field
var model = ref_match[1],
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; }
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
// row
new instance.web.DataSet(this.view, column.relation)
.name_get([value], function (names) {
.name_get([value]).then(function (names) {
if (!names.length) { return; }
record.set(column.id, names[0]);
});
+1 -1
View File
@@ -91,7 +91,7 @@ $(document).ready(function () {
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');
t.expect(ds.name_get([1, 2], null), function (r) {
strictEqual(r.method, 'name_get');