summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2016-08-16 18:28:23 +0200
committerSimon Lejeune <sle@openerp.com>2016-08-16 18:28:23 +0200
commitdbe90c26611fbc062cd38df0235bae78cbe4e898 (patch)
tree5bfe3e97cc909de6d6a149371dee043cdb611800
parentfc5d7d54ed855c9bdb3639a47de5c87f020c3b74 (diff)
[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.
-rw-r--r--addons/barcodes/static/src/js/inherited_form_widget_button.js2
1 files changed, 1 insertions, 1 deletions
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();
}
};