From e3354895266cc05bbc7cff28e79a2e3b6786bca0 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Mon, 17 Apr 2023 10:39:29 +0000 Subject: [PATCH] [FIX] point_of_sale: fix raceback when deleting orderline Steps to reproduce: - Activate customer display. - Open a pos session. - Open the customer display. - Add orderline. - Delete the orderline. Then there's traceback. This is caused by the fact that the `effect` used to update the customer display is synchronous, and when removing an order, `splice` is applied in multiple steps, and causes multiple notifications to the underlying reactive. At some of those steps, the reactive state is inconsistent (ie, one of the slots of the reactive array is empty) causing the call to map to result in an array with empty slots which cannot be used in `Object.fromEntries`. This commit fixes that my batching the updates to the customer display in the next microtask tick, meaning that the update will never be done with an inconsistent state. closes odoo/odoo#118743 Signed-off-by: Samuel Degueldre --- .../static/src/app/customer_display_service.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/app/customer_display_service.js b/addons/point_of_sale/static/src/app/customer_display_service.js index 6555b1be8de..27ae7a08f89 100644 --- a/addons/point_of_sale/static/src/app/customer_display_service.js +++ b/addons/point_of_sale/static/src/app/customer_display_service.js @@ -1,5 +1,6 @@ /** @odoo-module */ +import { batched } from "@point_of_sale/js/utils"; import { effect, Reactive } from "@point_of_sale/utils"; import { registry } from "@web/core/registry"; import { pick } from "@web/core/utils/objects"; @@ -136,7 +137,10 @@ export const customerDisplayService = { // of having it be a part of the chrome and having to propagate complexity everywhere. env.services.customer_display = display; // Register an effect to update the display automatically when anything it renders changes - effect((display) => display.update(), [display]); + effect( + batched((display) => display.update()), + [display] + ); }); return service;