From 61306c1d819815329a02f746f603aad821a32f60 Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Thu, 18 Apr 2024 16:29:06 +0200 Subject: [PATCH] [FIX] point_of_sale: add error message when image are not loaded Current behavior: When trying to print a receipt offline, the image will not be loaded and you get a traceback. Now the receipt is printed, and an error is logged in the console if the images couldn't be loaded Steps to reproduce: - Add a logo to the company - Launch PoS - In the browser devtools network tab turn the connection down - Do an order, and try to print the receipt - You get a traceback and the receipt is not printed opw-3811663 closes odoo/odoo#162451 Signed-off-by: Joseph Caburnay (jcb) --- .../point_of_sale/static/src/app/printer/printer_service.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/app/printer/printer_service.js b/addons/point_of_sale/static/src/app/printer/printer_service.js index ad07e55730c..d2cfd5eab3c 100644 --- a/addons/point_of_sale/static/src/app/printer/printer_service.js +++ b/addons/point_of_sale/static/src/app/printer/printer_service.js @@ -38,7 +38,11 @@ export class PrinterService { async print(component, props, options) { const el = await this.renderer.toHtml(component, props); // Load all images before printing - await loadAllImages(el); + try { + await loadAllImages(el); + } catch (e) { + console.error("Images could not be loaded correctly", e); + } return await this.printHtml(el, options); } is = () => Boolean(this.device?.printReceipt);