From fd5a5875e7b18b4b14cfdba498d15cfc45e1b439 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Fri, 6 May 2022 12:00:32 +0000 Subject: [PATCH] [FIX] pos_adyen: polling response of adyen on correct line closes odoo/odoo#90817 X-original-commit: 749e22335d871732c8c7c4e2bc798b811b26a034 Signed-off-by: Quentin Lejeune (qle) Signed-off-by: Masereel Pierre --- addons/pos_adyen/static/src/js/payment_adyen.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/pos_adyen/static/src/js/payment_adyen.js b/addons/pos_adyen/static/src/js/payment_adyen.js index ee3ccc92046..0b8c7eee1e2 100644 --- a/addons/pos_adyen/static/src/js/payment_adyen.js +++ b/addons/pos_adyen/static/src/js/payment_adyen.js @@ -28,6 +28,11 @@ var PaymentAdyen = PaymentInterface.extend({ this.most_recent_service_id = id; }, + pending_adyen_line() { + return this.pos.get_order().paymentlines.find( + paymentLine => paymentLine.payment_method.use_payment_terminal === 'adyen' && (!paymentLine.is_done())); + }, + // private methods _reset_state: function () { this.was_cancelled = false; @@ -38,7 +43,7 @@ var PaymentAdyen = PaymentInterface.extend({ _handle_odoo_connection_failure: function (data) { // handle timeout - var line = this.pos.get_order().selected_paymentline; + var line = this.pending_adyen_line(); if (line) { line.set_payment_status('retry'); } @@ -209,7 +214,7 @@ var PaymentAdyen = PaymentInterface.extend({ var notification = status.latest_response; var last_diagnosis_service_id = status.last_received_diagnosis_id; var order = self.pos.get_order(); - var line = order.selected_paymentline; + var line = self.pending_adyen_line(); if (self.last_diagnosis_service_id != last_diagnosis_service_id) { @@ -277,7 +282,7 @@ var PaymentAdyen = PaymentInterface.extend({ }, _adyen_handle_response: function (response) { - var line = this.pos.get_order().selected_paymentline; + var line = this.pending_adyen_line(); if (response.error && response.error.status_code == 401) { this._show_error(_t('Authentication failed. Please check your Adyen credentials.'));