From af8e411c7d350863d99989d2efea0653ea99bc39 Mon Sep 17 00:00:00 2001 From: "Pedram (PEBR)" Date: Wed, 28 Jun 2023 07:46:36 +0000 Subject: [PATCH] [FIX] point_of_sale: handle not finding a product by barcode Before this commit, if you scan a barcode that it's not related to a product it opened a popup and showed an error. The solution is to open the popup outside the `_getProductByBarcode` function. opw-3357131 closes odoo/odoo#126668 X-original-commit: dcd710dcc50b0d3f10f7bf0bdf0ce33360657439 Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: Pedram Bi Ria (pebr) --- .../static/src/app/screens/product_screen/product_screen.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js b/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js index 28db69d715c..2065c8f2f4a 100644 --- a/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js +++ b/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js @@ -146,8 +146,6 @@ export class ProductScreen extends ControlButtonsMixin(Component) { await this.pos._addProducts(foundProductIds); // assume that the result is unique. product = this.pos.db.get_product_by_id(foundProductIds[0]); - } else { - return this.popup.add(ErrorBarcodePopup, { code: code.base_code }); } } return product; @@ -155,7 +153,7 @@ export class ProductScreen extends ControlButtonsMixin(Component) { async _barcodeProductAction(code) { const product = await this._getProductByBarcode(code); if (!product) { - return; + return this.popup.add(ErrorBarcodePopup, { code: code.base_code }); } const options = await product.getAddProductOptions(code); // Do not proceed on adding the product when no options is returned. @@ -212,7 +210,7 @@ export class ProductScreen extends ControlButtonsMixin(Component) { const lotBarcode = parsed_results.find((element) => element.type === "lot"); const product = await this._getProductByBarcode(productBarcode); if (!product) { - return; + return this.popup.add(ErrorBarcodePopup, { code: productBarcode.base_code }); } const options = await product.getAddProductOptions(lotBarcode); await this.currentOrder.add_product(product, options);