changeset 9d3ea3a3586c in modules/purchase_amendment:default
details:
https://hg.tryton.org/modules/purchase_amendment?cmd=changeset&node=9d3ea3a3586c
description:
Use declarative index definition for ModelSQL
issue5757
review361251002
diffstat:
purchase.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diffs (34 lines):
diff -r df8bccdb549e -r 9d3ea3a3586c purchase.py
--- a/purchase.py Sun Oct 09 13:12:51 2022 +0200
+++ b/purchase.py Tue Oct 11 00:44:50 2022 +0200
@@ -2,7 +2,7 @@
# this repository contains the full copyright notices and license terms.
from trytond.i18n import gettext
-from trytond.model import ModelSQL, ModelView, Workflow, fields
+from trytond.model import Index, ModelSQL, ModelView, Workflow, fields
from trytond.modules.product import price_digits
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Bool, Eval, If
@@ -37,7 +37,7 @@
__name__ = 'purchase.amendment'
purchase = fields.Many2One(
- 'purchase.purchase', "Purchase", required=True, select=True,
+ 'purchase.purchase', "Purchase", required=True,
domain=[
('state', 'in', ['processing', 'done']),
],
@@ -67,6 +67,12 @@
@classmethod
def __setup__(cls):
super(Amendment, cls).__setup__()
+ t = cls.__table__()
+ cls._sql_indexes.add(
+ Index(
+ t,
+ (t.state, Index.Equality()),
+ where=t.state == 'draft'))
cls._order = [
('date', 'DESC'),
('id', 'DESC'),