diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-06-28 18:22:06 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-06-28 18:22:06 +0200 |
| commit | 4b4e8cdf7d1697ef4e04eb062db2a7ab395d24e1 (patch) | |
| tree | 8a835f504cb59ac5db840d0b99cd76f5efe206bd /addons/base | |
| parent | 3d81e16e9b1504be26dc891be0db895949035c53 (diff) | |
[fix] fixed some problems with m2o (too much on_change and "theorically unreachable state")
bzr revid: nicolas.vanhoren@openerp.com-20110628162206-3dowhy9t5ffj2mzp
Diffstat (limited to 'addons/base')
| -rw-r--r-- | addons/base/static/src/js/form.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index b2c74c920c3..8044c425661 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -1277,9 +1277,15 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({ }, _change_int_value: function(value) { this.value = value; - if (this.original_value === undefined || (this.value !== undefined && - ((this.original_value ? this.original_value[0] : null) !== (this.value ? this.value[0] : null)))) { - this.original_value = undefined; + var back_orig_value = this.original_value; + if (this.value === null || this.value) { + this.original_value = this.value; + } + if (back_orig_value === undefined) { // first use after a set_value() + return; + } + if (this.value !== undefined && ((back_orig_value ? back_orig_value[0] : null) + !== (this.value ? this.value[0] : null))) { this.on_ui_change(); } }, @@ -1292,7 +1298,7 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({ var real_set_value = function(rval) { self.tmp_value = undefined; _super.apply(self, rval); - self.original_value = rval; + self.original_value = undefined; self._change_int_ext_value(rval); }; if(typeof(value) === "number") { @@ -1312,7 +1318,7 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({ return this.tmp_value ? this.tmp_value : false; } if (this.value === undefined) - throw "theorically unreachable state"; + return this.original_value ? this.original_value[0] : false; return this.value ? this.value[0] : false; }, validate: function() { |
