From 37d414c23857d56a8c30dee32d2f13fcdb91c218 Mon Sep 17 00:00:00 2001 From: "Pedram (pebr)" Date: Tue, 20 Feb 2024 16:53:12 +0100 Subject: [PATCH] [FIX] point_of_sale: retain element in whenMounted Prior to this commit, the receipt element was cloned and appended to the render-container for web printing, then deleted after print callback. This approach failed on Android, leading to an empty page, as the cloned element was removed before printing. This commit resolves the issue by retaining the cloned element until the next clone addition to the container, at which point existing elements are removed. opw-3755682 closes odoo/odoo#154777 Signed-off-by: Joseph Caburnay (jcb) --- .../point_of_sale/static/src/app/printer/render_service.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/app/printer/render_service.js b/addons/point_of_sale/static/src/app/printer/render_service.js index 7f00e8b225c..1ed8b9d51d6 100644 --- a/addons/point_of_sale/static/src/app/printer/render_service.js +++ b/addons/point_of_sale/static/src/app/printer/render_service.js @@ -80,9 +80,13 @@ registry.category("services").add("renderer", renderService); */ const applyWhenMounted = async ({ el, container, callback }) => { const elClone = el.cloneNode(true); + const sameClassElements = container.querySelectorAll(`.${[...el.classList].join(".")}`); + // Remove all elements with the same class as the one we are about to add + sameClassElements.forEach(element => { + element.remove(); + }); container.appendChild(elClone); const res = await callback(elClone); - elClone.remove(); return res; };