diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-06-23 14:57:25 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-06-23 14:57:25 +0200 |
| commit | 7fc77495e047a5cd0588d6c92c01fc2ed9f041f0 (patch) | |
| tree | 7665375247607a60165dd2290a58e47474992d46 /addons/base/static/src/js | |
| parent | abf83d268559516d8c6de24567731390f496a327 (diff) | |
[fix] problem in get_value of m2o
bzr revid: nicolas.vanhoren@openerp.com-20110623125725-lzt263x8c7t0obmk
Diffstat (limited to 'addons/base/static/src/js')
| -rw-r--r-- | addons/base/static/src/js/form.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 62ffb997783..9a9f9738a6a 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -1080,6 +1080,7 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({ this.value = null; this.cm_id = _.uniqueId('m2o_cm_'); this.last_search = []; + this.tmp_value = undefined; }, start: function() { this._super(); @@ -1268,14 +1269,16 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({ value = value || null; var self = this; var _super = this._super; + this.tmp_value = value; var real_set_value = function(rval) { + this.tmp_value = undefined; _super.apply(self, rval); self.original_value = rval; self._change_int_ext_value(rval); }; if(typeof(value) === "number") { var dataset = new openerp.base.DataSetStatic(this.session, this.field.relation, []); - dataset.call("name_get", value, function(data) { + dataset.call("name_get", [value], function(data) { real_set_value(data.result[0]); }); } else { @@ -1283,6 +1286,12 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({ } }, get_value: function() { + if (this.tmp_value !== undefined) { + if (this.tmp_value instanceof Array) { + return this.tmp_value[0]; + } + return this.tmp_value; + } if (this.value === undefined) throw "theorically unreachable state"; return this.value ? this.value[0] : false; |
