[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.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user