[IMP] web: multi-click on save on view form (no fp)

When clicking on save several time when editing a view form it can be
saved several times which can be an issue for one to many.

The normal happenstance when saving should be as follow:

-> save (click)
-> wait write result
-> received write result
-> reload the form with updated data and updates buttons

But when clicking several time, it could become:

-> save (click)
-> wait write result
-> received write result
-> save (click)
-> wait write result
-> received write result
-> reload the form with updated data and updates buttons

This commit only reinstate the saving feature once the form is reloaded.

closes #11926
opw-671793

note: no need to forward-port
This commit is contained in:
Nicolas Lempereur 2016-05-04 13:14:25 +02:00
parent 859fe655d2
commit dd714ace55
1 changed files with 4 additions and 2 deletions

View File

@ -726,14 +726,16 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
$(e.target).attr("disabled", true);
return this.save().done(function(result) {
self.trigger("save", result);
self.reload().then(function() {
self.reload().always(function(){
$(e.target).attr("disabled", false);
}).then(function() {
self.to_view_mode();
var menu = instance.webclient.menu;
if (menu) {
menu.do_reload_needaction();
}
});
}).always(function(){
}).fail(function(){
$(e.target).attr("disabled", false);
});
},