Skip to content
Snippets Groups Projects
Commit a5f566b5 authored by Adrien Widart (awt)'s avatar Adrien Widart (awt)
Browse files

[FIX] barcodes: prevent `enter` if barcode


To reproduce the issue:
(Need `stock_barcode` and a real barcode scanner)
1. Create two products P01 and P02, each one with a barcode
2. Barcode > Operations > Receipts, Create
3. Scan P01
4. Scan P02
5. Click on the `+1` button on the line of P01
6. Scan P02

Error: Both lines are incremented. Scanning P01 should not impact the
quantity of P01

Because of step 5, the focus is still on that button when scanning
again P02 (step 6). Moreover, the scanner ends the barcode transmission
of P02 with an `enter` -> it will generate an event on the `+1` button,
which explains why the quantity of P01 is also incremented.

OPW-3232437

closes odoo/odoo#122125

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 180139cd
No related branches found
No related tags found
No related merge requests found
......@@ -51,10 +51,13 @@ export const barcodeService = {
/**
* check if we have a barcode, and trigger appropriate events
*/
function checkBarcode() {
function checkBarcode(ev) {
let str = barcodeInput ? barcodeInput.value : bufferedBarcode;
str = barcodeService.cleanBarcode(str);
if (str.length >= 3) {
if (ev) {
ev.preventDefault();
}
handleBarcode(str, currentTarget);
}
if (barcodeInput) {
......@@ -97,7 +100,7 @@ export const barcodeService = {
clearTimeout(timeout);
if (isEndCharacter) {
checkBarcode();
checkBarcode(ev);
} else {
bufferedBarcode += ev.key;
timeout = setTimeout(checkBarcode, barcodeService.maxTimeBetweenKeysInMs);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment