diff --git a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js index 3155f111ab8..819f28d9952 100644 --- a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js +++ b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js @@ -58,20 +58,17 @@ odoo.define('point_of_sale.PaymentScreen', function (require) { } addNewPaymentLine({ detail: paymentMethod }) { // original function: click_paymentmethods - if (this.currentOrder.electronic_payment_in_progress()) { + let result = this.currentOrder.add_paymentline(paymentMethod); + if (result){ + NumberBuffer.reset(); + return true; + } + else{ this.showPopup('ErrorPopup', { title: this.env._t('Error'), body: this.env._t('There is already an electronic payment in progress.'), }); return false; - } else { - this.currentOrder.add_paymentline(paymentMethod); - NumberBuffer.reset(); - this.payment_interface = paymentMethod.payment_terminal; - if (this.payment_interface) { - this.currentOrder.selected_paymentline.set_payment_status('pending'); - } - return true; } } _updateSelectedPaymentline() { diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 4a57b3a8868..fc3f92d33ba 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -2619,14 +2619,22 @@ class Order extends PosModel { /* ---- Payment Lines --- */ add_paymentline(payment_method) { this.assert_editable(); - var newPaymentline = Payment.create({},{order: this, payment_method:payment_method, pos: this.pos}); - this.paymentlines.add(newPaymentline); - this.select_paymentline(newPaymentline); - if(this.pos.config.cash_rounding){ - this.selected_paymentline.set_amount(0); + if (this.electronic_payment_in_progress()) { + return false; + } else { + var newPaymentline = Payment.create({},{order: this, payment_method:payment_method, pos: this.pos}); + this.paymentlines.add(newPaymentline); + this.select_paymentline(newPaymentline); + if(this.pos.config.cash_rounding){ + this.selected_paymentline.set_amount(0); + } + newPaymentline.set_amount(this.get_due()); + + if (payment_method.payment_terminal) { + newPaymentline.set_payment_status('pending'); + } + return newPaymentline; } - newPaymentline.set_amount(this.get_due()); - return newPaymentline; } get_paymentlines(){ return this.paymentlines;