From c91542adfb8a1431a620103ed69cf4787e3e5b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 21 Jan 2025 18:43:23 +0100 Subject: [PATCH] Do not retrieve current transaction to fetch model attribute It is the transaction stored on the instance that must be used and which is set by the context manager. --- trytond/trytond/model/modelstorage.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trytond/trytond/model/modelstorage.py b/trytond/trytond/model/modelstorage.py index 6f14016112..5583144dd1 100644 --- a/trytond/trytond/model/modelstorage.py +++ b/trytond/trytond/model/modelstorage.py @@ -1778,7 +1778,7 @@ class ModelStorage(Model): kwargs_cache = {} pysoned_ctx = {} - transaction = Transaction() + transaction = self._transaction def create_instances(Model, value, cache_key=None): cache_key = (Model, cache_key) @@ -1839,11 +1839,11 @@ class ModelStorage(Model): model2ids = {} model2cache = {} # Read the data - with Transaction().set_current_transaction(self._transaction), \ + with Transaction().set_current_transaction(transaction), \ self._transaction.set_user(self._user), \ self._transaction.reset_context(), \ self._transaction.set_context(self._context), \ - without_check_access() as transaction: + without_check_access(): if (self.id in self._cache and name in self._cache[self.id] and ffields.keys() <= set(self._cache[self.id]._keys())): # Use values from cache