From dbe90c26611fbc062cd38df0235bae78cbe4e898 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Tue, 16 Aug 2016 18:28:23 +0200 Subject: [PATCH] [FIX] stock_barcode: correctly check when to execute "O-BTN" It's possible to trigger click on form view's button with the help of the "barcode_trigger" attributes. However, we don't want to be able to execute clicks on items that aren't clickable by the user. That's why we wrote the following condition: if the elem is visible OR is a child of a .dropdown-menu, we trigger the click. The second condition was always true since we used the jquery's parent function which return an empty list when no result, and an empty list is truthy. --- addons/barcodes/static/src/js/inherited_form_widget_button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/barcodes/static/src/js/inherited_form_widget_button.js b/addons/barcodes/static/src/js/inherited_form_widget_button.js index 79cf6deb823..08475ee199b 100644 --- a/addons/barcodes/static/src/js/inherited_form_widget_button.js +++ b/addons/barcodes/static/src/js/inherited_form_widget_button.js @@ -16,7 +16,7 @@ var ButtonBarcodeHandlerMixin = _.extend({}, BarcodeHandlerMixin, { this.on_barcode_scanned = function(barcode) { var match = barcode.match(/O-BTN\.(.+)/); if (match && match[1] === self.node.attrs.barcode_trigger && - (self.$el.is(':visible') || self.$el.parent('.dropdown-menu'))) { + (self.$el.is(':visible') || self.$el.parent('.dropdown-menu').length)) { self.on_click(); } };