diff options
| author | Christophe Matthieu <chm@odoo.com> | 2015-05-06 12:00:13 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-05-06 12:09:29 +0200 |
| commit | 9de486eef515145e64cb20fe97d97e7ef6926b81 (patch) | |
| tree | 9c91672c87b7f162800b2a34c93c2712e64f2e1d | |
| parent | 083775508207bf4f948bc725a1c6a43673acd4f7 (diff) | |
[FIX] web: x2many field: when a record is create (with wizard) the starting_ids must be empty because if they are a onchange, the field recieve again the create commands (duplicate lines). Add destroy method to release the view event garbage
| -rw-r--r-- | addons/web/static/src/js/views/form_relational_widgets.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index a6ffcd3d058..81752617940 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -513,9 +513,7 @@ var AbstractManyField = common.AbstractField.extend({ this.set('value', []); this.starting_ids = []; this.has_not_committed_changes = false; - this.view.on("load_record", this, function () { - self.starting_ids = self.get('value').slice(); - }); + this.view.on("load_record", this, this._on_load_record); this.dataset.on('dataset_changed', this, function() { self.has_not_committed_changes = true; // the editable lists change the dataset without call AbstractManyField methods @@ -529,6 +527,10 @@ var AbstractManyField = common.AbstractField.extend({ }); }, + _on_load_record: function (record) { + this.starting_ids = record.id ? record[this.name].slice() : []; + }, + set_value: function(ids) { ids = (ids || []).slice(); if (_.find(ids, function(id) { return typeof(id) === "string"; } )) { @@ -723,6 +725,11 @@ var AbstractManyField = common.AbstractField.extend({ is_false: function() { return _(this.get('value')).isEmpty(); }, + + destroy: function () { + this.view.off("load_record", this, this._on_load_record); + this._super(); + } }); |
