[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 #13135
opw-686025
This commit is contained in:
Nicolas Martinelli
2016-08-16 13:06:03 +02:00
parent 842bf793f5
commit 0350ab81b8
@@ -1523,13 +1523,17 @@ var FieldStatus = common.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');
if (this.view.is_disabled) {
return;
}
var val;
if (ul.attr('disabled')) {
return;
}
if (this.field.type == "many2one") {
val = parseInt($li.data("id"), 10);
}
@@ -1546,13 +1550,16 @@ var FieldStatus = common.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),
});
var FieldMonetary = FieldFloat.extend({