From 1f43fa9dfe727719168f6d19aa8d1b8ca14d5f72 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 29 Oct 2015 11:33:16 +0100 Subject: [PATCH] [FIX] web: do not write twice when updating value The issue occurs for example in the Sale dashboard, when the user changes the target amount. If the user changes the value, then directly clicks outside of the field, the method on_change_input will be called twice: the first time because of the event 'change input', the second time because of the event 'blur input'. This makes an unnecessary write, which can cause an error due to concurrent access. This prevents the execution of the write related to the event 'change input' in this case. If the user changes the value but clicks on 'Enter', the focus is still on the field so the update is done correctly. Courtesy of Quentin Smetz (qsm@odoo.com) opw-653086 --- addons/web/static/src/js/widgets/progress_bar.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web/static/src/js/widgets/progress_bar.js b/addons/web/static/src/js/widgets/progress_bar.js index abe1009b1fa..6ccd1e74f28 100644 --- a/addons/web/static/src/js/widgets/progress_bar.js +++ b/addons/web/static/src/js/widgets/progress_bar.js @@ -72,6 +72,9 @@ var ProgressBar = Widget.extend({ on_change_input: function(e) { var $input = $(e.target); + if(e.type === 'change' && !$input.is(':focus')) { + return; + } if(isNaN($input.val())) { this.do_warn(_t("Wrong value entered!"), _t("Only Integer Value should be valid.")); } else {