From 3aa2d05213b43233e3016899a1f3fdbcc4fe0b76 Mon Sep 17 00:00:00 2001 From: AH-Yussef Date: Tue, 9 Apr 2024 12:25:53 +0200 Subject: [PATCH] [FIX] pos_restaurant: avoid printing empty receipts when tip after payment is active Steps to reproduce: - Install POS app. - Go to POS settings and enable: - Is a Bar/Restaurant - Tips > Add tip after payment - Open a POS session -if first time, add a floor and a table- - Add a product - Click on payment - Choose a payment method - Click on Close Tab - The print popup is shown twice in a row with an empty subtotal amount. Investigation: - Inside the `TipReceipt` template, the `total` is not shown as the class lacks a getter for it [1] - Also when there is no printer, we won't fallback to the web printer as it's annoying to the cashier. [1]: https://github.com/odoo/odoo/blob/1d49034782e3ff0e4384bad4e927a895e2a97839/addons/pos_restaurant/static/src/app/tip_receipt/tip_receipt.xml#L13-L16 opw-3836549 closes odoo/odoo#161056 Signed-off-by: Adrien Guilliams (adgu) --- .../pos_restaurant/static/src/app/tip_receipt/tip_receipt.js | 4 ++++ addons/pos_restaurant/static/src/app/tip_screen/tip_screen.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/pos_restaurant/static/src/app/tip_receipt/tip_receipt.js b/addons/pos_restaurant/static/src/app/tip_receipt/tip_receipt.js index 0cd25bee68f..c37a082d1c0 100644 --- a/addons/pos_restaurant/static/src/app/tip_receipt/tip_receipt.js +++ b/addons/pos_restaurant/static/src/app/tip_receipt/tip_receipt.js @@ -7,4 +7,8 @@ export class TipReceipt extends Component { static template = "pos_restaurant.TipReceipt"; static components = { ReceiptHeader }; static props = ["headerData", "data", "total"]; + + get total() { + return this.props.total; + } } diff --git a/addons/pos_restaurant/static/src/app/tip_screen/tip_screen.js b/addons/pos_restaurant/static/src/app/tip_screen/tip_screen.js index 62a3a335cd3..de56b2a12da 100644 --- a/addons/pos_restaurant/static/src/app/tip_screen/tip_screen.js +++ b/addons/pos_restaurant/static/src/app/tip_screen/tip_screen.js @@ -123,7 +123,7 @@ export class TipScreen extends Component { data: receipts[i], total: this.env.utils.formatCurrency(this.totalAmount), }, - { webPrintFallback: true } + { webPrintFallback: false } ); } }