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

        issue5757
        review361251002
diffstat:

 account.py |  6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (23 lines):

diff -r 3ec4ff78c572 -r 5db66bdb80c7 account.py
--- a/account.py        Mon May 02 17:09:38 2022 +0200
+++ b/account.py        Tue Oct 11 00:44:49 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, Unique, Workflow, fields
+from trytond.model import Index, ModelSQL, ModelView, Unique, Workflow, fields
 from trytond.model.exceptions import AccessError
 from trytond.modules.account.exceptions import AccountMissing
 from trytond.modules.currency.fields import Monetary
@@ -126,6 +126,10 @@
             ('invoice_line_unique', Unique(table, table.invoice_line),
                 'account_invoice_defer.msg_defer_invoice_line_unique'),
             ]
+        cls._sql_indexes.add(
+            Index(
+                table, (table.state, Index.Equality()),
+                where=table.state.in_(['draft', 'running'])))
         cls.journal.domain = [
             If(Eval('type') == 'out',
                 ('type', 'in', cls._journal_types('out')),

Reply via email to