From f8bebc407bb94d458b9d76460c8eb8bc850067b7 Mon Sep 17 00:00:00 2001 From: Horacio Tellez Date: Thu, 14 Apr 2022 13:02:27 +0000 Subject: [PATCH] [FIX] payment: do not add fee for validation transaction When making transaction with 'validation' type and where fees were active, fees were added to the amount. This behaviour is problematic because validation operations are used for tokenization for example where no credit should charged to the customer. Now validation operations have no fees even if fees are active on the acquirer. Task - 2784765 closes odoo/odoo#96712 X-original-commit: 69b04e753ab4e90e68b9d3e678ebea277586e7ac Signed-off-by: Antoine Vandevenne (anv) --- addons/payment/models/payment_transaction.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/addons/payment/models/payment_transaction.py b/addons/payment/models/payment_transaction.py index b1eae1c03a0..5b7bfee0897 100644 --- a/addons/payment/models/payment_transaction.py +++ b/addons/payment/models/payment_transaction.py @@ -206,11 +206,14 @@ class PaymentTransaction(models.Model): 'partner_phone': partner.phone, }) - # Compute fees - currency = self.env['res.currency'].browse(values.get('currency_id')).exists() - values['fees'] = acquirer._compute_fees( - values.get('amount', 0), currency, partner.country_id - ) + # Compute fees, for validation transactions fees are zero + if values.get('operation') == 'validation': + values['fees'] = 0 + else: + currency = self.env['res.currency'].browse(values.get('currency_id')).exists() + values['fees'] = acquirer._compute_fees( + values.get('amount', 0), currency, partner.country_id, + ) # Include acquirer-specific create values values.update(self._get_specific_create_values(acquirer.provider, values))