[FIX] point_of_sale: payment by terminal when settle due

When we want to settle the amount due by a customer, we can choose a
payment method through a Popup. When the payement method choosed in the
popup is linked to a terminal the payment line is added, but don't have
a correct status, so we cannot send the request to the terminal.

To correctly add the payment and related status, we are moving some
logic that was set in the payment screen into the method that create the
payment line on the order.

closes odoo/odoo#85873

X-original-commit: 325772042c3d55034842e5710ab398237531e494
Signed-off-by: Masereel Pierre <pim@odoo.com>
This commit is contained in:
Pierre Masereel
2022-03-06 10:57:11 +00:00
parent 0df8a0d955
commit 7655963ef9
2 changed files with 21 additions and 16 deletions
@@ -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() {
+15 -7
View File
@@ -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;