[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 <sad@odoo.com>
This commit is contained in:
committed by
Samuel Degueldre
parent
68ed032b8a
commit
e335489526
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user