changeset 52843af96d31 in modules/attendance:default
details:
https://hg.tryton.org/modules/attendance?cmd=changeset&node=52843af96d31
description:
Use declarative index definition for ModelSQL
issue5757
review361251002
diffstat:
attendance.py | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diffs (33 lines):
diff -r 32fd4ee9cfca -r 52843af96d31 attendance.py
--- a/attendance.py Sun Oct 09 13:27:55 2022 +0200
+++ b/attendance.py Tue Oct 11 00:44:49 2022 +0200
@@ -13,7 +13,7 @@
from trytond import backend
from trytond.cache import Cache
from trytond.i18n import gettext
-from trytond.model import ModelSQL, ModelView, Workflow, fields
+from trytond.model import Index, ModelSQL, ModelView, Workflow, fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
from trytond.tools import timezone as tz
@@ -167,12 +167,19 @@
state = fields.Selection([
('draft', 'Draft'),
('closed', 'Closed'),
- ], "State", select=True, readonly=True, sort=False,
+ ], "State", readonly=True, sort=False,
help="The current state of the attendance period.")
@classmethod
def __setup__(cls):
super().__setup__()
+ t = cls.__table__()
+ cls._sql_indexes.add(
+ Index(
+ t,
+ (t.company, Index.Equality()),
+ (t.state, Index.Equality()),
+ (t.ends_at, Index.Range(order='DESC'))))
cls._transitions |= set((
('draft', 'closed'),
('closed', 'draft'),