[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 <pimodoo@users.noreply.github.com>
This commit is contained in:
+1
-13
@@ -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';
|
||||
|
||||
+11
-5
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user