From b8e62185c43aa4d09f15eb8a61b191a4017367bf Mon Sep 17 00:00:00 2001 From: vlst Date: Mon, 13 Nov 2023 11:25:11 +0100 Subject: [PATCH] [FIX] point_of_sale: check payment amount In the pos one cannot make a payment that is larger than the required amount if there is no cash payment option. In order to check this there is a condition in the `payment_screen`. The problem is that this condition fails to spot certain cases. Steps to reproduce: - open a pos that has only one payment method and this method is `bank`; - buy an item for 10 $; - try to pay 11 $; - notice error popup; ( this is the expected behaviour ) - now try to create another payment line for any amount ( ex 9999 $ ) - as this is a different payment line the error popup will not appear; --> this is wrong In this commit we change the condition such that it detects this type of error too. closes odoo/odoo#141778 Signed-off-by: Adrien Guilliams (adgu) --- .../static/src/app/screens/payment_screen/payment_screen.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js index a4d49e6a4d1..17fcf020599 100644 --- a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js +++ b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js @@ -156,7 +156,6 @@ export class PaymentScreen extends Component { ); if ( !hasCashPaymentMethod && - this.currentOrder.get_due() + this.selectedPaymentLine.amount > 0 && amount > this.currentOrder.get_due() + this.selectedPaymentLine.amount ) { this.selectedPaymentLine.set_amount(0); @@ -272,9 +271,9 @@ export class PaymentScreen extends Component { this.currentOrder.finalized = true; // 1. Save order to server. - this.env.services.ui.block() + this.env.services.ui.block(); const syncOrderResult = await this.pos.push_single_order(this.currentOrder); - this.env.services.ui.unblock() + this.env.services.ui.unblock(); if (syncOrderResult instanceof ConnectionLostError) { this.pos.showScreen(this.nextScreen);