diff options
| author | Christophe Matthieu <chm@odoo.com> | 2015-07-07 09:41:43 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-07-13 11:50:32 +0200 |
| commit | 809cdbb153e9d9211fccaff47895524c93c2c635 (patch) | |
| tree | 9e539e70fbc27f3a01234f22ac99026d22b009ce /addons/web/static/src/js/views/form_relational_widgets.js | |
| parent | 66025268e18e165cf6891b8c72951e2b85cb37d1 (diff) | |
[IMP] web: use a mutex on the object instead of create one in the send_commands method: no crossed change values, keep internal_dataset_changed for other widgets (like editable list)
Diffstat (limited to 'addons/web/static/src/js/views/form_relational_widgets.js')
| -rw-r--r-- | addons/web/static/src/js/views/form_relational_widgets.js | 16 |
1 files changed, 7 insertions, 9 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 d6702ca9082..65fb75fe34f 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -448,12 +448,14 @@ var AbstractManyField = common.AbstractField.extend({ this.dataset.child_name = this.name; this.set('value', []); this.starting_ids = []; + this.mutex = new utils.Mutex(); this.has_not_committed_changes = false; this.view.on("load_record", this, this._on_load_record); this.dataset.on('dataset_changed', this, function() { self.has_not_committed_changes = true; + // don't trigger changes if all commands are not resolved // the editable lists change the dataset without call AbstractManyField methods - if (!self.internal_dataset_changed) { + if (self.mutex.def.state() === "resolved" && !self.internal_dataset_changed) { self.trigger("change:commands"); } }); @@ -575,15 +577,12 @@ var AbstractManyField = common.AbstractField.extend({ send_commands: function (command_list, options) { var self = this; var def = $.Deferred(); - var mutex = new utils.Mutex(); var dataset = this.dataset; var res = true; options = options || {}; - var tmp = this.internal_dataset_changed; - this.internal_dataset_changed = true; _.each(command_list, function(command) { - mutex.exec(function() { + self.mutex.exec(function() { var id = command[1]; switch (command[0]) { case COMMANDS.CREATE: @@ -621,10 +620,9 @@ var AbstractManyField = common.AbstractField.extend({ }); }); - mutex.exec(function () { - def.resolve(res); - self.internal_dataset_changed = tmp; + this.mutex.def.then(function () { self.trigger("change:commands"); + def.resolve(res); }); return def; }, @@ -681,7 +679,7 @@ var AbstractManyField = common.AbstractField.extend({ }, is_valid: function () { - return !this.has_not_committed_changes && this._super(); + return this.mutex.def.state() === "resolved" && !this.has_not_committed_changes && this._super(); }, is_false: function() { |
