book:caching for line, settings: cache clear
This commit is contained in:
parent
02bde17f6b
commit
17a4499ac7
2 changed files with 13 additions and 1 deletions
|
@ -21,4 +21,13 @@ class AssetSetting(ModelSingleton, ModelSQL, ModelView):
|
|||
model_name='cashbook.book', ondelete='RESTRICT',
|
||||
help='Profit and loss on sale of assets are recorded in the cash book.')
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
""" clear cache-values
|
||||
"""
|
||||
MemCache = Pool().get('cashbook.memcache')
|
||||
|
||||
MemCache._cashbook_value_cache.clear_all()
|
||||
super(AssetSetting, cls).write(*args)
|
||||
|
||||
# end AssetSetting
|
||||
|
|
5
book.py
5
book.py
|
@ -15,7 +15,7 @@ from sql import Literal
|
|||
from sql.functions import CurrentDate
|
||||
from sql.aggregate import Sum
|
||||
from sql.conditionals import Case, Coalesce
|
||||
from trytond.modules.cashbook.model import CACHEKEY_CURRENCY
|
||||
from trytond.modules.cashbook.model import CACHEKEY_CURRENCY, CACHEKEY_CASHBOOK
|
||||
from .asset import CACHEKEY_ASSETRATE
|
||||
|
||||
|
||||
|
@ -282,6 +282,7 @@ class Book(SymbolMixin, metaclass=PoolMeta):
|
|||
query = [{
|
||||
'model': 'cashbook.line',
|
||||
'query': [('cashbook.parent', 'child_of', [x.id])],
|
||||
'cachekey': CACHEKEY_CASHBOOK % x.id,
|
||||
}, {
|
||||
'model': 'currency.currency.rate',
|
||||
'query': [('currency.id', '=', x.currency.id)],
|
||||
|
@ -422,9 +423,11 @@ class Book(SymbolMixin, metaclass=PoolMeta):
|
|||
query = [{
|
||||
'model': 'cashbook.line',
|
||||
'query': [('cashbook.parent', 'child_of', [x.id])],
|
||||
'cachekey': CACHEKEY_CASHBOOK % x.id,
|
||||
}, {
|
||||
'model': 'currency.currency.rate',
|
||||
'query': [('currency.id', '=', x.currency.id)],
|
||||
'cachekey': CACHEKEY_CURRENCY % x.currency.id,
|
||||
}, {
|
||||
'model': 'investment.rate',
|
||||
'query': [('asset.id', '=', x.asset.id)],
|
||||
|
|
Loading…
Reference in a new issue