[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) <jcb@odoo.com>
This commit is contained in:
Pedram (pebr)
2024-02-26 11:41:55 +00:00
parent 7c6d5394fb
commit 37d414c238
@@ -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;
};