book: add caching for line
This commit is contained in:
parent
624a5bff55
commit
39309783b6
5 changed files with 51 additions and 10 deletions
7
model.py
7
model.py
|
@ -7,7 +7,7 @@ from trytond.model import MultiValueMixin, ValueMixin, fields, Unique, Model
|
|||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.cache import MemoryCache
|
||||
from datetime import timedelta, datetime
|
||||
from datetime import timedelta
|
||||
from decimal import Decimal
|
||||
from sql import With, Literal
|
||||
from sql.functions import Function
|
||||
|
@ -15,6 +15,7 @@ from sql.conditionals import Coalesce
|
|||
|
||||
ENABLE_CACHE = True
|
||||
CACHEKEY_CURRENCY = 'currency-%s'
|
||||
CACHEKEY_CASHBOOK = 'cashbook-%s'
|
||||
|
||||
|
||||
class ArrayAgg(Function):
|
||||
|
@ -140,8 +141,6 @@ class MemCache(Model):
|
|||
if ENABLE_CACHE == False:
|
||||
return '-'
|
||||
|
||||
dt1 = datetime.now()
|
||||
print('-- get_key_by_record:', name, record.id)
|
||||
fname = [name, str(record.id)]
|
||||
fname.extend(addkeys)
|
||||
|
||||
|
@ -185,8 +184,6 @@ class MemCache(Model):
|
|||
|
||||
if 'cachekey' in line.keys():
|
||||
key = cls.store_value(line['cachekey'], fname[-1])
|
||||
|
||||
print('-- get_key_by_record-END:', datetime.now() - dt1, '-'.join(fname))
|
||||
return '-'.join(fname)
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue