changeset 7ce9ae74a136 in modules/sale_amendment:default
details: 
https://hg.tryton.org/modules/sale_amendment?cmd=changeset&node=7ce9ae74a136
description:
        Use declarative index definition for ModelSQL

        issue5757
        review361251002
diffstat:

 sale.py |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (34 lines):

diff -r 1850c80da7c2 -r 7ce9ae74a136 sale.py
--- a/sale.py   Sun Oct 09 13:12:51 2022 +0200
+++ b/sale.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__ = 'sale.amendment'
 
     sale = fields.Many2One(
-        'sale.sale', "Sale", required=True, select=True,
+        'sale.sale', "Sale", 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'),

Reply via email to