mirror of
https://github.com/NaN-tic/trytond-stock_lot_deactivatable.git
synced 2023-12-14 03:22:55 +01:00
Clear lot cache after SQL UPDATE. #048200
This commit is contained in:
parent
3233a9617a
commit
79fa2a439d
18
stock.py
18
stock.py
|
@ -72,6 +72,24 @@ class Lot(DeactivableMixin, metaclass=PoolMeta):
|
|||
cursor = Transaction().connection.cursor()
|
||||
cursor.execute(*query)
|
||||
|
||||
# Clear cache to ensure lots are reloaded if accessed after UPDATE
|
||||
|
||||
# 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()
|
||||
|
||||
|
||||
class Move(metaclass=PoolMeta):
|
||||
__name__ = 'stock.move'
|
||||
|
|
Loading…
Reference in a new issue