From 8a8bad1e9cc81d82964e9d992770886884d3436b Mon Sep 17 00:00:00 2001 From: Albert Cervera i Areny Date: Mon, 22 Nov 2021 17:01:20 +0100 Subject: [PATCH] Clear lot cache after SQL UPDATE. #048200 --- stock.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/stock.py b/stock.py index 1a4b381..2cd3a05 100644 --- a/stock.py +++ b/stock.py @@ -77,18 +77,14 @@ class Lot(DeactivableMixin, metaclass=PoolMeta): # Increase transaction counter Transaction().counter += 1 - # Clean local cache - for record in lots: - local_cache = record._local_cache.get(record.id) - if local_cache: - local_cache.clear() - # Clean cursor cache - for cache in Transaction().cache.values(): - if cls.__name__ in cache: - for record in lots: - if record.id in cache[cls.__name__]: - cache[cls.__name__][record.id].clear() + for cache in list(Transaction().cache.values()): + for cache in (cache, + list(cache.get('_language_cache', {}).values())): + if cls.__name__ in cache: + cache_cls = cache[cls.__name__] + for record in lots: + cache_cls.pop(record.id, None) class Move(metaclass=PoolMeta):