From f44076ff693e9ece40cbce254902a2e70c348041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Didderen?= Date: Tue, 27 Oct 2026 21:26:45 +0100 Subject: [PATCH] [FIX] account_ebics - Do not commit during tests in the Enterprise import _process_bank_statement_oe commits after each statement. Under tests this left the test transaction. Skip the commit when the registry is in test mode or the current thread is a test thread. --- account_ebics/models/ebics_file.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index 05792be..9454e35 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -3,6 +3,7 @@ import base64 import logging +import threading from copy import deepcopy from sys import exc_info from traceback import format_exception @@ -507,11 +508,16 @@ class EbicsFile(models.Model): """ We execute a cr.commit() after every statement import since we get a 'savepoint does not exist' error when using 'with self.env.cr.savepoint()'. + The commit is skipped when running tests. """ + testing = self.env.registry.in_test_mode() or getattr( + threading.current_thread(), "testing", False + ) for st_data in st_datas: try: self._create_bank_statement_oe(res, st_data) - self.env.cr.commit() # pylint: disable=E8102 + if not testing: + self.env.cr.commit() # pylint: disable=E8102 except UserError as e: # noqa: PERF203 msg = "".join(e.args) msg += "\n"