changeset 979429edf5b3 in modules/marketing_automation:default
details:
https://hg.tryton.org/modules/marketing_automation?cmd=changeset&node=979429edf5b3
description:
Use declarative index definition for ModelSQL
issue5757
review361251002
diffstat:
marketing_automation.py | 13 ++++++++++++-
party.py | 2 +-
2 files changed, 13 insertions(+), 2 deletions(-)
diffs (49 lines):
diff -r 3c2c6d74f4b1 -r 979429edf5b3 marketing_automation.py
--- a/marketing_automation.py Sat Oct 01 15:35:33 2022 +0200
+++ b/marketing_automation.py Tue Oct 11 00:44:49 2022 +0200
@@ -26,7 +26,8 @@
from trytond.config import config
from trytond.i18n import gettext
from trytond.model import (
- EvalEnvironment, ModelSQL, ModelView, Unique, Workflow, dualmethod, fields)
+ EvalEnvironment, Index, ModelSQL, ModelView, Unique, Workflow, dualmethod,
+ fields)
from trytond.pool import Pool
from trytond.pyson import Eval, If, PYSONDecoder
from trytond.report import Report
@@ -85,6 +86,11 @@
@classmethod
def __setup__(cls):
super().__setup__()
+ t = cls.__table__()
+ cls._sql_indexes.add(
+ Index(
+ t, (t.state, Index.Equality()),
+ where=t.state.in_(['draft', 'running'])))
cls._transitions |= set((
('draft', 'running'),
('running', 'stopped'),
@@ -767,6 +773,11 @@
('activity_record_unique', Unique(t, t.activity, t.record),
'marketing_automation.msg_activity_record_unique'),
]
+ cls._sql_indexes.add(
+ Index(
+ t,
+ (t.state, Index.Equality()),
+ where=t.state.in_(['waiting'])))
cls._transitions |= set((
('waiting', 'done'),
('waiting', 'cancelled'),
diff -r 3c2c6d74f4b1 -r 979429edf5b3 party.py
--- a/party.py Sat Oct 01 15:35:33 2022 +0200
+++ b/party.py Tue Oct 11 00:44:49 2022 +0200
@@ -42,7 +42,7 @@
__name__ = 'party.party-unsubscribed-marketing.automation.scenario'
party = fields.Many2One(
- 'party.party', "Party", required=True, select=True, ondelete='CASCADE')
+ 'party.party', "Party", required=True, ondelete='CASCADE')
scenario = fields.Many2One(
'marketing.automation.scenario', "Scenario",
required=True, ondelete='CASCADE')