[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#122200 X-original-commit: a5f566b57ace1d82e77f56f4c059eb595350e1cf Signed-off-by: William Henrotin (whe) <whe@odoo.com> Signed-off-by: Adrien Widart (awt) <awt@odoo.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user