add worker-based precalculation of cashbook-values
This commit is contained in:
parent
9ef465f40f
commit
5d8f924960
17 changed files with 1060 additions and 98 deletions
25
line.py
25
line.py
|
@ -15,7 +15,7 @@ from sql import Literal
|
|||
from sql.functions import DatePart
|
||||
from sql.conditionals import Case
|
||||
from .book import sel_state_book
|
||||
from .mixin import SecondCurrencyMixin, MemCacheIndexMx
|
||||
from .mixin import SecondCurrencyMixin
|
||||
from .const import DEF_NONE
|
||||
|
||||
|
||||
|
@ -49,9 +49,7 @@ STATES = {
|
|||
DEPENDS = ['state', 'state_cashbook']
|
||||
|
||||
|
||||
class Line(
|
||||
SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL,
|
||||
ModelView):
|
||||
class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
||||
'Cashbook Line'
|
||||
__name__ = 'cashbook.line'
|
||||
|
||||
|
@ -1037,6 +1035,8 @@ class Line(
|
|||
def create(cls, vlist):
|
||||
""" add debit/credit
|
||||
"""
|
||||
ValueStore = Pool().get('cashbook.values')
|
||||
|
||||
vlist = [x.copy() for x in vlist]
|
||||
for values in vlist:
|
||||
values.update(cls.add_values_from_splitlines(values))
|
||||
|
@ -1056,18 +1056,26 @@ class Line(
|
|||
recname='%(date)s|%(descr)s' % {
|
||||
'date': date_txt,
|
||||
'descr': values.get('description', '-')}))
|
||||
return super(Line, cls).create(vlist)
|
||||
records = super(Line, cls).create(vlist)
|
||||
|
||||
if records:
|
||||
ValueStore.update_books(ValueStore.get_book_by_line(records))
|
||||
return records
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
""" deny update if cashbook.line!='open',
|
||||
add or update debit/credit
|
||||
"""
|
||||
ValueStore = Pool().get('cashbook.values')
|
||||
|
||||
actions = iter(args)
|
||||
to_write = []
|
||||
to_update = []
|
||||
for lines, values in zip(actions, actions):
|
||||
cls.check_permission_write(lines, values)
|
||||
|
||||
to_update.extend(lines)
|
||||
for line in lines:
|
||||
if line.reconciliation:
|
||||
# deny state-change to 'edit' if line is
|
||||
|
@ -1111,12 +1119,19 @@ class Line(
|
|||
|
||||
super(Line, cls).write(*to_write)
|
||||
|
||||
if to_update:
|
||||
ValueStore.update_books(ValueStore.get_book_by_line(to_update))
|
||||
|
||||
@classmethod
|
||||
def delete(cls, lines):
|
||||
""" deny delete if book is not 'open' or wf is not 'edit'
|
||||
"""
|
||||
ValueStore = Pool().get('cashbook.values')
|
||||
|
||||
cls.check_permission_delete(lines)
|
||||
to_update = ValueStore.get_book_by_line(lines)
|
||||
super(Line, cls).delete(lines)
|
||||
ValueStore.update_books(to_update)
|
||||
|
||||
# end Line
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue