book: add caching for line
This commit is contained in:
parent
1793d3653e
commit
d5bc62ca78
5 changed files with 51 additions and 10 deletions
13
book.py
13
book.py
|
@ -15,7 +15,7 @@ from datetime import date
|
|||
from sql.aggregate import Sum
|
||||
from sql.conditionals import Case
|
||||
from .model import order_name_hierarchical, sub_ids_hierarchical, \
|
||||
AnyInArray, CACHEKEY_CURRENCY
|
||||
AnyInArray, CACHEKEY_CURRENCY, CACHEKEY_CASHBOOK
|
||||
|
||||
|
||||
STATES = {
|
||||
|
@ -262,6 +262,16 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
}
|
||||
return recname
|
||||
|
||||
def get_cachekeys_by_hierarchy(self):
|
||||
""" generate keys for all cashbooks above us
|
||||
"""
|
||||
CBook = Pool().get('cashbook.book')
|
||||
|
||||
return [CACHEKEY_CASHBOOK % x.id
|
||||
for x in CBook.search([
|
||||
('parent', 'parent_of', [self.id]),
|
||||
], order=[('id', 'ASC')])]
|
||||
|
||||
@classmethod
|
||||
def get_balance_of_cashbook_sql(cls):
|
||||
""" sql for balance of a single cashbook
|
||||
|
@ -371,6 +381,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
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)],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue