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
42
line.py
42
line.py
|
@ -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 ModelView, ModelSQL, Workflow, fields, Check
|
||||
from trytond.model import ModelView, ModelSQL, Workflow, fields, Check, Index
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Eval, If, Or, Bool, Date
|
||||
from trytond.transaction import Transaction
|
||||
|
@ -53,24 +53,24 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
|||
__name__ = 'cashbook.line'
|
||||
|
||||
cashbook = fields.Many2One(
|
||||
string='Cashbook', required=True, select=True,
|
||||
string='Cashbook', required=True,
|
||||
model_name='cashbook.book', ondelete='CASCADE', readonly=True,
|
||||
domain=[('btype', '!=', None)])
|
||||
date = fields.Date(
|
||||
string='Date', required=True, select=True,
|
||||
string='Date', required=True,
|
||||
states=STATES, depends=DEPENDS)
|
||||
month = fields.Function(fields.Integer(
|
||||
string='Month', readonly=True),
|
||||
'on_change_with_month', searcher='search_month')
|
||||
number = fields.Char(string='Number', readonly=True)
|
||||
description = fields.Text(
|
||||
string='Description', select=True,
|
||||
string='Description',
|
||||
states=STATES, depends=DEPENDS)
|
||||
descr_short = fields.Function(fields.Char(
|
||||
string='Description', readonly=True),
|
||||
'on_change_with_descr_short', searcher='search_descr_short')
|
||||
category = fields.Many2One(
|
||||
string='Category', select=True,
|
||||
string='Category',
|
||||
model_name='cashbook.category', ondelete='RESTRICT',
|
||||
states={
|
||||
'readonly': Or(
|
||||
|
@ -98,7 +98,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
|||
|
||||
bookingtype = fields.Selection(
|
||||
string='Type', required=True,
|
||||
help='Type of Booking', selection=sel_bookingtype, select=True,
|
||||
help='Type of Booking', selection=sel_bookingtype,
|
||||
states=STATES, depends=DEPENDS)
|
||||
bookingtype_string = bookingtype.translated('bookingtype')
|
||||
amount = fields.Numeric(
|
||||
|
@ -145,7 +145,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
|||
|
||||
# link to lines created by this record
|
||||
reference = fields.Many2One(
|
||||
string='Reference', readonly=True, select=True,
|
||||
string='Reference', readonly=True,
|
||||
states={
|
||||
'invisible': ~Bool(Eval('reference')),
|
||||
}, model_name='cashbook.line', ondelete='CASCADE',
|
||||
|
@ -197,7 +197,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
|||
|
||||
state = fields.Selection(
|
||||
string='State', required=True, readonly=True,
|
||||
select=True, selection=sel_linetype)
|
||||
selection=sel_linetype)
|
||||
state_string = state.translated('state')
|
||||
state_cashbook = fields.Function(fields.Selection(
|
||||
string='State of Cashbook',
|
||||
|
@ -223,6 +223,30 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
|||
cls._order.insert(0, ('date', 'ASC'))
|
||||
cls._order.insert(0, ('state', 'ASC'))
|
||||
t = cls.__table__()
|
||||
|
||||
cls._sql_indexes.update({
|
||||
Index(
|
||||
t,
|
||||
(t.cashbook, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.date, Index.Range(order='ASC'))),
|
||||
Index(
|
||||
t,
|
||||
(t.description, Index.Similarity())),
|
||||
Index(
|
||||
t,
|
||||
(t.category, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.bookingtype, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.state, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.reference, Index.Range())),
|
||||
})
|
||||
cls._sql_constraints.extend([
|
||||
('state_val2',
|
||||
Check(t, t.state.in_(['edit', 'check', 'done', 'recon'])),
|
||||
|
@ -656,7 +680,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
|||
|
||||
@fields.depends('category')
|
||||
def on_change_with_category_view(self, name=None):
|
||||
""" show optimizef form of category for list-view
|
||||
""" show optimized form of category for list-view
|
||||
"""
|
||||
Configuration = Pool().get('cashbook.configuration')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue