[IMP] payment: prevent validation transactions from creating payments
Before commit 139dd9d, only validation transactions made with a validity check (transfer of a small amount with immediate refund) led to the creation of an `account.payment` record for the reconciliation. As that amount was never perceived, there was in fact nothing to reconcile. With commit 139dd9d, it is possible to make $0-validations (the validity check is handled by the provider). As this feature now sheds light on the flawed behavior described above, it has been decided to entirely stop creating `account.payment` records for validation transactions. This commit thus prevents the post-processing of validation transactions from preparing their reconciliation. task-2494916 closes odoo/odoo#72137 X-original-commit: f460d7a5a995cd7b934d32f82b50aede43efbace Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com> Signed-off-by: Antoine Vandevenne (anv) <AntoineVDV@users.noreply.github.com>
This commit is contained in:
@@ -797,13 +797,17 @@ class PaymentTransaction(models.Model):
|
||||
def _reconcile_after_done(self):
|
||||
""" Post relevant fiscal documents and create missing payments.
|
||||
|
||||
As there is nothing to reconcile for validation transactions, no payment is created for
|
||||
them. This is also true for validations with a validity check (transfer of a small amount
|
||||
with immediate refund) because validation amounts are not included in payouts.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Validate invoices automatically once the transaction is confirmed
|
||||
self.invoice_ids.filtered(lambda inv: inv.state == 'draft').action_post()
|
||||
|
||||
# Create and post missing payments
|
||||
for tx in self.filtered(lambda t: not t.payment_id):
|
||||
# Create and post missing payments for transactions requiring reconciliation
|
||||
for tx in self.filtered(lambda t: t.operation != 'validation' and not t.payment_id):
|
||||
tx._create_payment()
|
||||
|
||||
def _create_payment(self, **extra_create_values):
|
||||
|
||||
@@ -5,3 +5,4 @@ from . import http_common
|
||||
from . import multicompany_common
|
||||
from . import test_flows
|
||||
from . import test_multicompany_flows
|
||||
from . import test_transactions
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests import tagged
|
||||
|
||||
from odoo.addons.payment.tests.common import PaymentCommon
|
||||
|
||||
|
||||
@tagged('-at_install', 'post_install')
|
||||
class TestTransactions(PaymentCommon):
|
||||
|
||||
def test_no_payment_for_validations(self):
|
||||
tx = self.create_transaction(flow='dummy', operation='validation') # Overwrite the flow
|
||||
tx._reconcile_after_done()
|
||||
payment_count = self.env['account.payment'].search_count(
|
||||
[('payment_transaction_id', '=', tx.id)]
|
||||
)
|
||||
self.assertEqual(payment_count, 0, "validation transactions should not create payments")
|
||||
Reference in New Issue
Block a user