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

        issue5757
        review361251002
diffstat:

 payment.py |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (44 lines):

diff -r 1ab113a47dc2 -r 3f805f5c02d1 payment.py
--- a/payment.py        Sun Sep 25 20:26:21 2022 +0200
+++ b/payment.py        Tue Oct 11 00:44:49 2022 +0200
@@ -16,7 +16,7 @@
 from trytond.config import config
 from trytond.i18n import gettext
 from trytond.model import (
-    DeactivableMixin, ModelSQL, ModelView, Unique, Workflow, dualmethod,
+    DeactivableMixin, Index, ModelSQL, ModelView, Unique, Workflow, dualmethod,
     fields)
 from trytond.modules.account_payment.exceptions import (
     PaymentValidationError, ProcessError)
@@ -693,7 +693,7 @@
             ('processing', "Processing"),
             ('succeeded', "Succeeded"),
             ('failed', "Failed"),
-            ], "State", readonly=True, select=True, sort=False)
+            ], "State", readonly=True, sort=False)
 
     stripe_idempotency_key = fields.Char(
         "Stripe Idempotency Key", readonly=True, strip=False)
@@ -722,6 +722,13 @@
     @classmethod
     def __setup__(cls):
         super().__setup__()
+        t = cls.__table__()
+        cls._sql_indexes.add(
+            Index(
+                t,
+                (t.state, Index.Equality()),
+                where=t.state.in_([
+                        'draft', 'submitted', 'approved', 'processing'])))
         cls.__access__.add('payment')
         cls._transitions |= set((
                 ('draft', 'submitted'),
@@ -1311,7 +1318,7 @@
     "Stripe Customer"
     __name__ = 'account.payment.stripe.customer'
     _history = True
-    party = fields.Many2One('party.party', "Party", required=True, select=True,
+    party = fields.Many2One('party.party', "Party", required=True,
         states={
             'readonly': Eval('stripe_customer_id') | Eval('stripe_token'),
             })

Reply via email to