diff options
| author | Joren Van Onder <jov@odoo.com> | 2016-03-18 12:45:49 +0100 |
|---|---|---|
| committer | Joren Van Onder <jov@odoo.com> | 2016-03-18 13:11:25 +0100 |
| commit | fe76e6bc364de1566bfea3492715607502ad2477 (patch) | |
| tree | 0cd3f2f576a58050c4a4a9fff6039d7f21584e0d /addons/barcodes/static/src/js/form_view_barcode_handler.js | |
| parent | b6847a0537b892d521264c672388241acfe86237 (diff) | |
[FIX] barcodes: first qualify the quantity event before handling it
Introduced by 5bb64d40d0b94b252c2e29e6a050ae37fbd87b0f. Before doing
anything we should first ensure that the quantity keypress event targets
body (and that it is a number, but that's less important). Before this
we didn't do that and thus the _display_no_edit_mode_warning was given
when people where just typing in the associated thread of a picking.
opw-672350
Diffstat (limited to 'addons/barcodes/static/src/js/form_view_barcode_handler.js')
| -rw-r--r-- | addons/barcodes/static/src/js/form_view_barcode_handler.js | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/addons/barcodes/static/src/js/form_view_barcode_handler.js b/addons/barcodes/static/src/js/form_view_barcode_handler.js index 572913c1b54..a6fa4b55adf 100644 --- a/addons/barcodes/static/src/js/form_view_barcode_handler.js +++ b/addons/barcodes/static/src/js/form_view_barcode_handler.js @@ -64,30 +64,33 @@ var FormViewBarcodeHandler = common.AbstractField.extend(BarcodeHandlerMixin, { var self = this; var character = String.fromCharCode(event.which); - if (this.form_view.get('actual_mode') === 'view') { - this._display_no_edit_mode_warning(); - } else if ($(event.target).is('body') && /[0-9]/.test(character)) { // only catch the event if we're not focused in - // another field and it's a number - var field = this.form_view.fields[this.m2x_field]; - var view = field.viewmanager.active_view; - - if (this.last_scanned_barcode) { - var new_qty = window.prompt(_t('Set quantity'), character) || "0"; - new_qty = new_qty.replace(',', '.'); - var record = this._get_records(field).find(function(record) { - return record.get('product_barcode') === self.last_scanned_barcode; - }); - if (record) { - var values = {}; - values[this.quantity_field] = parseFloat(new_qty); - field.data_update(record.get('id'), values).then(function () { - view.controller.reload_record(record); + // only catch the event if we're not focused in + // another field and it's a number + if ($(event.target).is('body') && /[0-9]/.test(character)) { + if (this.form_view.get('actual_mode') === 'view') { + this._display_no_edit_mode_warning(); + } else { + var field = this.form_view.fields[this.m2x_field]; + var view = field.viewmanager.active_view; + + if (this.last_scanned_barcode) { + var new_qty = window.prompt(_t('Set quantity'), character) || "0"; + new_qty = new_qty.replace(',', '.'); + var record = this._get_records(field).find(function(record) { + return record.get('product_barcode') === self.last_scanned_barcode; }); + if (record) { + var values = {}; + values[this.quantity_field] = parseFloat(new_qty); + field.data_update(record.get('id'), values).then(function () { + view.controller.reload_record(record); + }); + } else { + this._display_no_last_scanned_warning(); + } } else { this._display_no_last_scanned_warning(); } - } else { - this._display_no_last_scanned_warning(); } } }, |
