[FIX] web: prevent double-click on statusbar

When double-clicking on the statusbar widget, two calls to write are
performed. This can cause unwanted behavior, and when the `write` method
takes a lot of time to process, it's not possible to prevent it
server-side.

Courtesy of @gurneyalex and @aab-odoo

Closes #13134
opw-686025

FORWARD-PORT UP TO SAAS-6!
This commit is contained in:
Nicolas Martinelli 2016-08-16 11:53:49 +02:00
parent 71594f5958
commit c2fe9fe0e6
1 changed files with 9 additions and 2 deletions

View File

@ -6145,10 +6145,14 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
return fields;
});
},
on_click_stage: function (ev) {
on_click_stage: _.debounce(function (ev) {
var self = this;
var $li = $(ev.currentTarget);
var ul = $li.closest('.oe_form_field_status');
var val;
if (ul.attr('disabled')) {
return;
}
if (this.field.type == "many2one") {
val = parseInt($li.data("id"), 10);
}
@ -6165,13 +6169,16 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
this.view.recursive_save().done(function() {
var change = {};
change[self.name] = val;
ul.attr('disabled', true);
self.view.dataset.write(self.view.datarecord.id, change).done(function() {
self.view.reload();
}).always(function() {
ul.removeAttr('disabled');
});
});
}
}
},
}, 300),
});
instance.web.form.FieldMonetary = instance.web.form.FieldFloat.extend({