changeset 3695d028b14f in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=3695d028b14f
description:
        Do not skip eager load for field in cache but depending on non-cached 
fields

        and filter sibling ids only if all the needed fields are in caches.

        issue11481
        review419131003
diffstat:

 trytond/model/modelstorage.py |  20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diffs (40 lines):

diff -r ba9156b0e87d -r 3695d028b14f trytond/model/modelstorage.py
--- a/trytond/model/modelstorage.py     Wed Jun 08 09:19:40 2022 +0200
+++ b/trytond/model/modelstorage.py     Wed Jun 08 09:21:38 2022 +0200
@@ -1598,7 +1598,11 @@
                         = self._cache[self.id][name]
                 return value
             else:
-                skip_eager = name in self._cache[self.id]
+                skip_eager = (
+                    name in self._cache[self.id]
+                    and not field.context
+                    and (not getattr(field, 'datetime_field', None)
+                        or field.datetime_field in self._cache[self.id]))
         except KeyError:
             skip_eager = False
 
@@ -1664,14 +1668,18 @@
         delete_records = self._transaction.delete_records.get(
             self.__name__, set())
 
+        def cached(id_):
+            names = set()
+            if id_ in self._cache:
+                names.update(self._cache[id_]._keys())
+            if id_ in self._local_cache:
+                names.update(self._local_cache[id_]._keys())
+            return names
+
         def filter_(id_):
             return (id_ == self.id  # Ensure the value is read
                 or (id_ not in delete_records
-                    and (
-                        id_ not in self._cache
-                        or name not in self._cache[id_])
-                    and (id_ not in self._local_cache
-                        or name not in self._local_cache[id_])))
+                    and not ffields.keys() <= cached(id_)))
 
         def unique(ids):
             s = set()

Reply via email to