[FIX] web: failing onchanges should not prevent to save
This patch is related to 82adba4714
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.
This commit is contained in:
parent
89e179971a
commit
c12a2e1d16
|
@ -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,15 +803,13 @@ 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() {
|
||||
}).done(function(result) {
|
||||
self.$el.removeClass('oe_form_dirty');
|
||||
});
|
||||
});
|
||||
},
|
||||
_process_save: function(save_obj) {
|
||||
var self = this;
|
||||
|
|
Loading…
Reference in New Issue