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
book.py
42
book.py
|
@ -3,7 +3,9 @@
|
|||
# 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, Check, tree
|
||||
from trytond.model import (
|
||||
Workflow, ModelView, ModelSQL, fields, Check,
|
||||
tree, Index)
|
||||
from trytond.pyson import Eval, Or, Bool, Id, Len
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
|
@ -59,13 +61,13 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
|
||||
company = fields.Many2One(
|
||||
string='Company', model_name='company.company',
|
||||
required=True, select=True, ondelete="RESTRICT")
|
||||
required=True, ondelete="RESTRICT")
|
||||
name = fields.Char(
|
||||
string='Name', required=True, states=STATES, depends=DEPENDS)
|
||||
description = fields.Text(
|
||||
string='Description', states=STATES, depends=DEPENDS)
|
||||
btype = fields.Many2One(
|
||||
string='Type', select=True,
|
||||
string='Type',
|
||||
help='A cash book with type can contain postings. ' +
|
||||
'Without type is a view.',
|
||||
model_name='cashbook.type', ondelete='RESTRICT',
|
||||
|
@ -79,16 +81,16 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
string='Feature', readonly=True,
|
||||
states={'invisible': True}), 'on_change_with_feature')
|
||||
owner = fields.Many2One(
|
||||
string='Owner', required=True, select=True,
|
||||
string='Owner', required=True,
|
||||
model_name='res.user', ondelete='SET NULL',
|
||||
states=STATES, depends=DEPENDS)
|
||||
reviewer = fields.Many2One(
|
||||
string='Reviewer', select=True,
|
||||
string='Reviewer',
|
||||
help='Group of users who have write access to the cashbook.',
|
||||
model_name='res.group', ondelete='SET NULL',
|
||||
states=STATES, depends=DEPENDS)
|
||||
observer = fields.Many2One(
|
||||
string='Observer', select=True,
|
||||
string='Observer',
|
||||
help='Group of users who have read-only access to the cashbook.',
|
||||
model_name='res.group', ondelete='SET NULL',
|
||||
states=STATES, depends=DEPENDS)
|
||||
|
@ -158,7 +160,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
'on_change_with_currency_digits')
|
||||
|
||||
currency = fields.Many2One(
|
||||
string='Currency', select=True,
|
||||
string='Currency',
|
||||
model_name='currency.currency',
|
||||
states={
|
||||
'readonly': Or(
|
||||
|
@ -196,6 +198,32 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
cls._order.insert(0, ('rec_name', 'ASC'))
|
||||
cls._order.insert(0, ('state', 'ASC'))
|
||||
t = cls.__table__()
|
||||
cls._sql_indexes.update({
|
||||
Index(
|
||||
t,
|
||||
(t.btype, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.parent, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.company, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.currency, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.state, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.owner, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.reviewer, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.observer, Index.Equality())),
|
||||
})
|
||||
cls._sql_constraints.extend([
|
||||
('state_val',
|
||||
Check(t, t.state.in_(['open', 'closed', 'archive'])),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue