From 92e04dea0c69f79bef7fc826a408158319a4606b Mon Sep 17 00:00:00 2001 From: pedrambiria Date: Fri, 21 Oct 2022 13:22:59 +0000 Subject: [PATCH] [FIX] point_of_sale: reset number buffer when the select order line Before this commit: if you add two products in PoS and try to change the quantity for the first one, it works fine, but when you click on the other order line and try to update the quantity, it uses the previous number buffer. The solution is to reset the number buffer after selecting the order line. closes odoo/odoo#103834 Issue: https://github.com/odoo/odoo/issues/103230 X-original-commit: 51f6a6798ce2cc3c23a2fc55280cbd1a80df6bec Signed-off-by: Trinh Jacky (trj) Signed-off-by: Pedram Bi Ria (pebr) --- .../js/Screens/ProductScreen/ProductScreen.js | 4 ++++ .../static/tests/tours/ProductScreen.tour.js | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js b/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js index 158cfc4daf7..19d935e3426 100644 --- a/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js +++ b/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js @@ -16,6 +16,7 @@ odoo.define('point_of_sale.ProductScreen', function(require) { setup() { super.setup(); useListener('update-selected-orderline', this._updateSelectedOrderline); + useListener('select-line', this._selectLine); useListener('set-numpad-mode', this._setNumpadMode); useListener('click-product', this._clickProduct); useListener('click-partner', this.onClickPartner); @@ -161,6 +162,9 @@ odoo.define('point_of_sale.ProductScreen', function(require) { NumberBuffer.reset(); this.env.pos.numpadMode = mode; } + _selectLine() { + NumberBuffer.reset(); + } async _updateSelectedOrderline(event) { if (this.env.pos.numpadMode === 'quantity' && this.env.pos.disallowLineQuantityChange()) { let order = this.env.pos.get_order(); diff --git a/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js b/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js index f532bb59f1f..8fc7c15b2a0 100644 --- a/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js +++ b/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js @@ -66,6 +66,26 @@ odoo.define('point_of_sale.tour.ProductScreen', function (require) { ProductScreen.do.clickSubcategory('Chairs'); ProductScreen.check.productIsDisplayed('Letter Tray'); ProductScreen.do.clickHomeCategory(); + + // Add two orderlines and update quantity + ProductScreen.do.clickDisplayedProduct('Whiteboard Pen'); + ProductScreen.do.clickDisplayedProduct('Wall Shelf Unit'); + ProductScreen.do.clickOrderline('Whiteboard Pen', '1.0'); + ProductScreen.check.selectedOrderlineHas('Whiteboard Pen', '1.0'); + ProductScreen.do.pressNumpad('2'); + ProductScreen.check.selectedOrderlineHas('Whiteboard Pen', '2.0'); + ProductScreen.do.clickOrderline('Wall Shelf Unit', '1.0'); + ProductScreen.check.selectedOrderlineHas('Wall Shelf Unit', '1.0'); + ProductScreen.do.pressNumpad('2'); + ProductScreen.check.selectedOrderlineHas('Wall Shelf Unit', '2.0'); + ProductScreen.do.pressNumpad('Backspace'); + ProductScreen.check.selectedOrderlineHas('Wall Shelf Unit', '0.0'); + ProductScreen.do.pressNumpad('Backspace'); + ProductScreen.check.selectedOrderlineHas('Whiteboard Pen', '2.0'); + ProductScreen.do.pressNumpad('Backspace'); + ProductScreen.check.selectedOrderlineHas('Whiteboard Pen', '0.0'); + ProductScreen.do.pressNumpad('Backspace'); + ProductScreen.check.orderIsEmpty(); // Add multiple orderlines then delete each of them until empty ProductScreen.do.clickDisplayedProduct('Whiteboard Pen');