From d5fce03459ec9e330ffdca3e1221321f2282d28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Qui=C3=B1ones?= Date: Wed, 6 Aug 2025 00:49:17 +0000 Subject: [PATCH] [IMP] payment_authorize: avoid setting VOID transactions as canceled This commit removes calls to _set_canceled() for VOID-type transactions. For proper reconciliation, VOID transactions must remain in the posted state and should not be marked as canceled in the payment.transaction record. To identify voided payment.transaction records, the context "transaction_voided" is provided. --- addons/payment_authorize/models/payment_transaction.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/payment_authorize/models/payment_transaction.py b/addons/payment_authorize/models/payment_transaction.py index b729adfa7b135d..98f567a5e4f293 100644 --- a/addons/payment_authorize/models/payment_transaction.py +++ b/addons/payment_authorize/models/payment_transaction.py @@ -107,8 +107,7 @@ def _send_refund_request(self, amount_to_refund=None): refund_tx = self.env['payment.transaction'] tx_status = tx_details.get('transaction', {}).get('transactionStatus') if tx_status in TRANSACTION_STATUS_MAPPING['voided']: - # The payment has been voided from Authorize.net side before we could refund it. - self._set_canceled() + self.with_context(avoid_cancel=True)._set_canceled() elif tx_status in TRANSACTION_STATUS_MAPPING['refunded']: # The payment has been refunded from Authorize.net side before we could refund it. We # create a refund tx on Odoo to reflect the move of the funds. @@ -235,7 +234,7 @@ def _process_notification_data(self, notification_data): if self.operation == 'validation': # Validation txs are authorized and then voided self._set_done() # If the refund went through, the validation tx is confirmed else: - self._set_canceled() + self.with_context(avoid_cancel=True)._set_canceled() elif status_type == 'refund' and self.operation == 'refund': self._set_done() # Immediately post-process the transaction as the post-processing will not be