From 3bbec520e9fda603e2e7a4bd45ad84d61d51cd0c Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 10 Feb 2021 19:04:56 +0000 Subject: [PATCH] [FIX] point_of_sale: select employee with pin by barcode When switching employee on point of sale, we may have a PIN to enter. If we enter the barcode and there is a PIN, we get an "Invalid Password" error. Why: ==== When we switch with a barcode 12, the barcode system will catch events and prevent their propagation: - {'type': 'keypress', 'key': 49} - {'type': 'keypress', 'key': 50} - {'type': 'keypress', 'key': 13} For respectively '1', '2', 'Newline'. If it match an employee, the PIN number modal is opened which will listen to KEYUP events => it receives very shortly: - {'type': 'KEYUP', 'key': 13} which is the newline character which follows the KEYPRESS. With a "Return" key received, the PIN modale closes with empty value and an error "Invalid Password" is shown. Solution: ========= Ignore the newline character if no number has been selected. opw-2448585 closes odoo/odoo#66466 X-original-commit: d056feb4ac885acc6c829c57531b985027d94daf Signed-off-by: Nicolas Lempereur (nle) Co-authored-by: Joseph Caburnay --- addons/point_of_sale/static/src/js/Popups/NumberPopup.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/point_of_sale/static/src/js/Popups/NumberPopup.js b/addons/point_of_sale/static/src/js/Popups/NumberPopup.js index 385007d5812..0c24b8cb0dd 100644 --- a/addons/point_of_sale/static/src/js/Popups/NumberPopup.js +++ b/addons/point_of_sale/static/src/js/Popups/NumberPopup.js @@ -47,6 +47,11 @@ odoo.define('point_of_sale.NumberPopup', function(require) { return this.state.buffer; } } + confirm(event) { + if (NumberBuffer.get()) { + super.confirm(); + } + } sendInput(key) { this.trigger('numpad-click-input', { key }); }