summaryrefslogtreecommitdiff
path: root/addons/barcodes/static/src/js
diff options
context:
space:
mode:
authorArnold Moyaux <arm@odoo.com>2018-04-12 15:20:17 +0200
committerArnold Moyaux <arm@odoo.com>2018-04-18 11:50:48 +0200
commita6e2830631be5b933c33bf7105aafc33e08665d5 (patch)
treee0aa59d4f29fbe9c90964ebb11ee806a33b1371c /addons/barcodes/static/src/js
parente5305ca8b718ffec27474e57d06fb54340c81707 (diff)
[FIX] barcode: do not trigger barcode on pending views
The check on the event target and the barcode target is done outside the check on barcode found. That result in a warning for each modal/form view that is pending. This commit do the check before doing any operations in order to directly stop if the event target is not similiar to listening barcode target
Diffstat (limited to 'addons/barcodes/static/src/js')
-rw-r--r--addons/barcodes/static/src/js/barcode_form_view.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/addons/barcodes/static/src/js/barcode_form_view.js b/addons/barcodes/static/src/js/barcode_form_view.js
index b5cad7a1509..015119c5830 100644
--- a/addons/barcodes/static/src/js/barcode_form_view.js
+++ b/addons/barcodes/static/src/js/barcode_form_view.js
@@ -283,15 +283,14 @@ FormController.include({
function (reserved) {return barcode.indexOf(reserved) === 0;});
var hasCommand = false;
var defs = [];
+ if (! $.contains(target, self.el)) {
+ return;
+ }
for (var k in self.activeBarcode) {
var activeBarcode = self.activeBarcode[k];
// Handle the case where there are several barcode widgets on the same page. Since the
// event is global on the page, all barcode widgets will be triggered. However, we only
// want to keep the event on the target widget.
- if (! $.contains(target, self.el)) {
- continue;
- }
-
var methods = self.activeBarcode[k].commands;
var method = prefixed ? methods[barcode] : methods.barcode;
if (method) {
@@ -323,6 +322,9 @@ FormController.include({
_quantityListener: function (event) {
var character = String.fromCharCode(event.which);
+ if (! $.contains(event.target, this.el)) {
+ return;
+ }
// only catch the event if we're not focused in
// another field and it's a number
if (!$(event.target).is('body, .modal') || !/[0-9]/.test(character)) {