caching für change_day1/month1/...

This commit is contained in:
Frederik Jaeckel 2023-01-08 20:56:27 +01:00
parent 8cfa54f693
commit 8503fd3e32
3 changed files with 66 additions and 11 deletions

30
rate.py
View file

@ -87,4 +87,34 @@ class Rate(SymbolMixin, ModelSQL, ModelView):
result[n][record[0]] = r1[n]
return result
@classmethod
def create(cls, vlist):
""" clear cache
"""
Asset = Pool().get('investment.asset')
Asset.values_cache_clear(
[x['asset'] for x in vlist],
['change_day1', 'change_month1', 'change_month3',
'change_month6', 'change_month12'],
)
return super(Rate, cls).create(vlist)
@classmethod
def write(cls, *args):
""" clear cache
"""
Asset = Pool().get('investment.asset')
asset_ids = []
actions = iter(args)
for rates, values in zip(actions, actions):
asset_ids.extend([x.asset.id for x in rates])
if len(asset_ids) > 0:
Asset.values_cache_clear(asset_ids,
['change_day1', 'change_month1', 'change_month3',
'change_month6', 'change_month12'])
super(Rate, cls).write(*args)
# Rate