Tryton 6.8: indexe neu, tests angepaßt

This commit is contained in:
Frederik Jaeckel 2023-06-03 19:13:05 +02:00
parent 2cf42eb9f6
commit 2b6731d071
11 changed files with 143 additions and 52 deletions

View file

@ -4,7 +4,7 @@
# full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields
from trytond.model import ModelView, ModelSQL, fields, Index
from trytond.pool import Pool
from trytond.pyson import Eval, If
from trytond.report import Report
@ -31,16 +31,16 @@ class SplitLine(SecondCurrencyMixin, MemCacheIndexMx, ModelSQL, ModelView):
line = fields.Many2One(
string='Line', required=True,
select=True, ondelete='CASCADE', model_name='cashbook.line',
ondelete='CASCADE', model_name='cashbook.line',
readonly=True)
description = fields.Text(
string='Description', states=STATES, depends=DEPENDS)
splittype = fields.Selection(
string='Type', required=True,
help='Type of split booking line', selection=sel_linetype,
states=STATES, depends=DEPENDS, select=True)
states=STATES, depends=DEPENDS)
category = fields.Many2One(
string='Category', select=True,
string='Category',
model_name='cashbook.category', ondelete='RESTRICT',
states={
'readonly': STATES['readonly'],
@ -63,7 +63,7 @@ class SplitLine(SecondCurrencyMixin, MemCacheIndexMx, ModelSQL, ModelView):
('owner.id', '=', Eval('owner_cashbook', -1)),
('id', '!=', Eval('cashbook', -1)),
('btype', '!=', None),
], select=True,
],
states={
'readonly': STATES['readonly'],
'invisible': Eval('splittype', '') != 'tr',
@ -110,6 +110,25 @@ class SplitLine(SecondCurrencyMixin, MemCacheIndexMx, ModelSQL, ModelView):
states={'invisible': True}, model_name='res.user'),
'on_change_with_owner_cashbook')
@classmethod
def __setup__(cls):
super(SplitLine, cls).__setup__()
t = cls.__table__()
cls._sql_indexes.update({
Index(
t,
(t.line, Index.Equality())),
Index(
t,
(t.splittype, Index.Equality())),
Index(
t,
(t.category, Index.Equality())),
Index(
t,
(t.booktransf, Index.Equality())),
})
@classmethod
def default_splittype(cls):
""" default category