diff options
| author | Denis Ledoux <dle@odoo.com> | 2014-09-08 18:21:20 +0200 |
|---|---|---|
| committer | Denis Ledoux <dle@odoo.com> | 2014-09-08 18:27:05 +0200 |
| commit | c12a2e1d1650d308e39cc2b396a76eed579e2595 (patch) | |
| tree | 0b1121646f398aa9fc292eabc2562fdc208b3c80 | |
| parent | 89e179971a5e7945919769cf7f30fbdacc53afca (diff) | |
[FIX] web: failing onchanges should not prevent to save
This patch is related to 82adba4714d9b809aad835d0d77e6b6f9fde8ddc
With the above patch, it wasn't possible anymore to save if an onchange failed. This isn't the expected behavior.
Besides, $.when.apply($, defs) is rejected as soon as one def fails, without waiting other defs to be either resolved or rejected.
This new patch allows to save if onchange fails, and wait for onchanges sequentially.
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 3fa9afea0bc..eca9f6549ee 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -586,7 +586,16 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM var self = this; return this.mutating_mutex.exec(function() { function iterate() { - var defs = []; + var start = $.Deferred(); + start.resolve(); + start = _.reduce(self.onchanges_defs, function(memo, d){ + return memo.then(function(){ + return d; + }, function(){ + return d; + }); + }, start); + var defs = [start]; _.each(self.fields, function(field) { defs.push(field.commit_value()); }); @@ -794,14 +803,12 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM var self = this; var save_obj = {prepend_on_create: prepend_on_create, ret: null}; this.save_list.push(save_obj); - return $.when.apply($, self.onchanges_defs).then(function(){ - return self._process_operations().then(function() { - if (save_obj.error) - return $.Deferred().reject(); - return $.when.apply($, save_obj.ret); - }).done(function() { - self.$el.removeClass('oe_form_dirty'); - }); + return self._process_operations().then(function() { + if (save_obj.error) + return $.Deferred().reject(); + return $.when.apply($, save_obj.ret); + }).done(function(result) { + self.$el.removeClass('oe_form_dirty'); }); }, _process_save: function(save_obj) { |
