From deb015a06970b088caa668e5b5f07c067fdd7e63 Mon Sep 17 00:00:00 2001 From: vlst Date: Mon, 26 Jun 2023 14:50:25 +0000 Subject: [PATCH] [FIX] pos*: Fix order removal pos*: point_of_sale, pos_restaurant When deleting an order, the restaurant override of the deletion function in `point_of_sale` interferes with the logic in such a way that we end up writing the order that needs to be deleted 2 times. This is obviously not the expected bahaviour. In this PR we remove the `override` from `pos_restaurant`, as it is no longer needed and we also add a mechanism that ensures that orders cannot be duplicated. closes odoo/odoo#126442 Task: 3383043 Signed-off-by: Adrien Guilliams (adgu) --- addons/point_of_sale/static/src/app/store/db.js | 10 ++++++---- .../static/src/js/Screens/TicketScreen.js | 13 ------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/addons/point_of_sale/static/src/app/store/db.js b/addons/point_of_sale/static/src/app/store/db.js index 6d7417d9c26..8fff088c09b 100644 --- a/addons/point_of_sale/static/src/app/store/db.js +++ b/addons/point_of_sale/static/src/app/store/db.js @@ -688,11 +688,13 @@ export class PosDB { * @param {object} order object. */ set_order_to_remove_from_server(order) { - if (order.server_id !== undefined) { - var to_remove = this.load("unpaid_orders_to_remove", []); - to_remove.push(order.server_id); - this.save("unpaid_orders_to_remove", to_remove); + if (order.server_id === undefined) { + return; } + const to_remove = new Set( + [this.load("unpaid_orders_to_remove", []), order.server_id].flat() + ); + this.save("unpaid_orders_to_remove", [...to_remove]); } /** * Get a list of server_ids of orders to be removed. diff --git a/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js b/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js index 66dafc852fe..8d5ac27076a 100644 --- a/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js +++ b/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js @@ -70,19 +70,6 @@ patch(TicketScreen.prototype, "pos_restaurant.TicketScreen", { } } }, - //@override - async onDeleteOrder(order) { - const _super = this._super; - if (this.pos.config.module_pos_restaurant) { - this.pos.setOrderToRemove(order); - await _super(...arguments); - if (!this.pos.table) { - await this.pos._removeOrdersFromServer(); - } - } else { - await _super(...arguments); - } - }, async setTip(order, serverId, amount) { try { const paymentline = order.get_paymentlines()[0];