Tryton 6.8: indexe neu, tests angepaßt
This commit is contained in:
parent
2cf42eb9f6
commit
2b6731d071
11 changed files with 143 additions and 52 deletions
|
@ -3,7 +3,7 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields, Index
|
||||
from trytond.pyson import Eval, If, Or
|
||||
from trytond.pool import Pool
|
||||
from trytond.report import Report
|
||||
|
@ -34,10 +34,10 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
__name__ = 'cashbook.recon'
|
||||
|
||||
cashbook = fields.Many2One(
|
||||
string='Cashbook', required=True, select=True,
|
||||
string='Cashbook', required=True,
|
||||
model_name='cashbook.book', ondelete='CASCADE', readonly=True)
|
||||
date = fields.Date(
|
||||
string='Date', required=True, select=True,
|
||||
string='Date', required=True,
|
||||
states=STATES, depends=DEPENDS)
|
||||
feature = fields.Function(fields.Char(
|
||||
string='Feature', readonly=True,
|
||||
|
@ -54,7 +54,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
states=STATES, depends=DEPENDS+['date_to'])
|
||||
date_to = fields.Date(
|
||||
string='End Date',
|
||||
required=True, select=True,
|
||||
required=True,
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
|
@ -98,7 +98,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
|
||||
state = fields.Selection(
|
||||
string='State', required=True, readonly=True,
|
||||
select=True, selection=sel_reconstate)
|
||||
selection=sel_reconstate)
|
||||
state_string = state.translated('state')
|
||||
state_cashbook = fields.Function(fields.Selection(
|
||||
string='State of Cashbook',
|
||||
|
@ -109,6 +109,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
def __setup__(cls):
|
||||
super(Reconciliation, cls).__setup__()
|
||||
cls._order.insert(0, ('date_from', 'DESC'))
|
||||
t = cls.__table__()
|
||||
cls._transitions |= set((
|
||||
('edit', 'check'),
|
||||
('check', 'done'),
|
||||
|
@ -128,6 +129,23 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
'depends': ['state'],
|
||||
},
|
||||
})
|
||||
cls._sql_indexes.update({
|
||||
Index(
|
||||
t,
|
||||
(t.cashbook, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.date, Index.Range())),
|
||||
Index(
|
||||
t,
|
||||
(t.date_to, Index.Range())),
|
||||
Index(
|
||||
t,
|
||||
(t.date_from, Index.Range(order='DESC'))),
|
||||
Index(
|
||||
t,
|
||||
(t.state, Index.Equality())),
|
||||
})
|
||||
|
||||
def check_overlap_dates(self):
|
||||
""" deny overlap of date_from/date_to between records of same cashbook
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue