From 72bd6b86c3360c41893a41b8a849cb3611417be9 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Mon, 20 Jun 2022 10:47:40 +0000 Subject: [PATCH] [FIX] point_of_sale: automatically create new order When in point_of_sale, the screen when getting out of the TicketScreen is the current order's screen. However, when all the orders are deleted, no new order is created, thus, pos crashes when clicking back button without manually creating a new order. With this fix, when the TicketScreen is closed (either by clicking an order, or clicking the TicketButton or clicking Back button), a new order is automatically created when there are no more orders. The sequence of the orders is also properly tracked which is important in the fiscal data modules. closes odoo/odoo#95876 Task-id: 2886099 X-original-commit: 20a04a70ba8b24349054522632a53a9701313329 Related: odoo/enterprise#29394 Signed-off-by: Masereel Pierre Signed-off-by: Joseph Caburnay (jcb) --- .../static/src/js/Screens/TicketScreen/TicketScreen.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js b/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js index 99ca55b6ac3..66a23aa76d2 100644 --- a/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js +++ b/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js @@ -233,6 +233,16 @@ odoo.define('point_of_sale.TicketScreen', function (require) { } //#endregion //#region PUBLIC METHODS + close() { + /** + * Automatically create new order when there is no currently active order. + * Important in fiscal modules to keep the sequence of the orders. + */ + if (this.env.pos.orders.length == 0) { + this.env.pos.add_new_order(); + } + super.close(); + } getSelectedSyncedOrder() { if (this._state.ui.filter == 'SYNCED') { return this._state.syncedOrders.cache[this._state.ui.selectedSyncedOrderId];