From 21b235d8fa8a9f5f2b848409a2c08ce9a76b5d6d Mon Sep 17 00:00:00 2001 From: Robin Heinz Date: Tue, 1 Jun 2021 09:40:33 +0000 Subject: [PATCH] [FIX] point_of_sale: Fix order management reprint infinite recursive loop The were few times where we ended up with a infinite recursion while clicking on an order in the order management screen. This lead to a browser stuck. Now we don't use a temporary screen anymore and use the same mechanism of the receiptScreen to print the order. closes odoo/odoo#71668 X-original-commit: 2ea13121cf82c4c9b069363cfd2ef2857fc8ccaf Signed-off-by: pimodoo --- .../ControlButtons/ReprintReceiptButton.js | 14 +------------- .../ReprintReceiptScreen.js | 16 +++++++++++----- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/addons/point_of_sale/static/src/js/Screens/OrderManagementScreen/ControlButtons/ReprintReceiptButton.js b/addons/point_of_sale/static/src/js/Screens/OrderManagementScreen/ControlButtons/ReprintReceiptButton.js index 913f98af4e6..5a227827295 100644 --- a/addons/point_of_sale/static/src/js/Screens/OrderManagementScreen/ControlButtons/ReprintReceiptButton.js +++ b/addons/point_of_sale/static/src/js/Screens/OrderManagementScreen/ControlButtons/ReprintReceiptButton.js @@ -6,7 +6,6 @@ odoo.define('point_of_sale.ReprintReceiptButton', function (require) { const PosComponent = require('point_of_sale.PosComponent'); const OrderManagementScreen = require('point_of_sale.OrderManagementScreen'); const Registries = require('point_of_sale.Registries'); - const OrderReceipt = require('point_of_sale.OrderReceipt'); const contexts = require('point_of_sale.PosContext'); class ReprintReceiptButton extends PosComponent { @@ -19,18 +18,7 @@ odoo.define('point_of_sale.ReprintReceiptButton', function (require) { const order = this.orderManagementContext.selectedOrder; if (!order) return; - if (this.env.pos.proxy.printer) { - const fixture = document.createElement('div'); - const orderReceipt = new (Registries.Component.get(OrderReceipt))(this, { order }); - await orderReceipt.mount(fixture); - const receiptHtml = orderReceipt.el.outerHTML; - const printResult = await this.env.pos.proxy.printer.print_receipt(receiptHtml); - if (!printResult.successful) { - this.showTempScreen('ReprintReceiptScreen', { order: order }); - } - } else { - this.showTempScreen('ReprintReceiptScreen', { order: order }); - } + this.showScreen('ReprintReceiptScreen', { order: order }); } } ReprintReceiptButton.template = 'ReprintReceiptButton'; diff --git a/addons/point_of_sale/static/src/js/Screens/OrderManagementScreen/ReprintReceiptScreen.js b/addons/point_of_sale/static/src/js/Screens/OrderManagementScreen/ReprintReceiptScreen.js index ef5d396f616..1bd8d332ed4 100644 --- a/addons/point_of_sale/static/src/js/Screens/OrderManagementScreen/ReprintReceiptScreen.js +++ b/addons/point_of_sale/static/src/js/Screens/OrderManagementScreen/ReprintReceiptScreen.js @@ -6,12 +6,18 @@ odoo.define('point_of_sale.ReprintReceiptScreen', function (require) { const ReprintReceiptScreen = (AbstractReceiptScreen) => { class ReprintReceiptScreen extends AbstractReceiptScreen { - confirm() { - this.props.resolve({ confirmed: true, payload: null }); - this.trigger('close-temp-screen'); + mounted() { + this.tryReprint(); } - tryReprint() { - this._printReceipt(); + confirm() { + this.showScreen('OrderManagementScreen'); + } + async tryReprint() { + if(this.env.pos.proxy.printer && this.env.pos.config.iface_print_skip_screen) { + let result = await this._printReceipt(); + if(result) + this.showScreen('OrderManagementScreen'); + } } } ReprintReceiptScreen.template = 'ReprintReceiptScreen';