[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) <adgu@odoo.com>
This commit is contained in:
vlst
2023-06-27 16:26:56 +02:00
parent 2222b6911e
commit deb015a069
2 changed files with 6 additions and 17 deletions
@@ -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.
@@ -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];