[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) <jcb@odoo.com> Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user