From 7fc77495e047a5cd0588d6c92c01fc2ed9f041f0 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 23 Jun 2011 14:57:25 +0200 Subject: [PATCH] [fix] problem in get_value of m2o bzr revid: nicolas.vanhoren@openerp.com-20110623125725-lzt263x8c7t0obmk --- addons/base/static/src/js/form.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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;