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

        issue5757
        review361251002
diffstat:

 account.py |  20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diffs (73 lines):

diff -r 90f0e03023ba -r 26675add0041 account.py
--- a/account.py        Sun Oct 09 19:07:16 2022 +0200
+++ b/account.py        Tue Oct 11 00:44:49 2022 +0200
@@ -8,7 +8,8 @@
 
 from trytond import backend
 from trytond.i18n import gettext
-from trytond.model import MatchMixin, ModelSQL, ModelView, Workflow, fields
+from trytond.model import (
+    Index, MatchMixin, ModelSQL, ModelView, Workflow, fields)
 from trytond.modules.company.model import CompanyValueMixin
 from trytond.modules.product import price_digits, round_price
 from trytond.pool import Pool, PoolMeta
@@ -89,7 +90,7 @@
     'Landed Cost'
     __name__ = 'account.landed_cost'
     _rec_name = 'number'
-    number = fields.Char('Number', select=True, readonly=True)
+    number = fields.Char("Number", readonly=True)
     company = fields.Many2One('company.company', 'Company', required=True,
         states={
             'readonly': Eval('state') != 'draft',
@@ -151,8 +152,11 @@
 
     @classmethod
     def __setup__(cls):
+        cls.number.search_unaccented = False
         super(LandedCost, cls).__setup__()
-
+        t = cls.__table__()
+        cls._sql_indexes.add(
+            Index(t, (t.state, Index.Equality()), where=t.state == 'draft'))
         cls._order = [
             ('number', 'DESC'),
             ('id', 'DESC'),
@@ -467,7 +471,7 @@
     __name__ = 'account.landed_cost-stock.shipment.in'
     landed_cost = fields.Many2One(
         'account.landed_cost', 'Landed Cost',
-        required=True, select=True, ondelete='CASCADE')
+        required=True, ondelete='CASCADE')
     shipment = fields.Many2One(
         'stock.shipment.in', 'Shipment', required=True, ondelete='CASCADE')
 
@@ -477,7 +481,7 @@
     __name__ = 'account.landed_cost-product.category'
     landed_cost = fields.Many2One(
         'account.landed_cost', 'Landed Cost',
-        required=True, select=True, ondelete='CASCADE')
+        required=True, ondelete='CASCADE')
     category = fields.Many2One(
         'product.category', "Category", required=True, ondelete='CASCADE')
 
@@ -487,7 +491,7 @@
     __name__ = 'account.landed_cost-product.product'
     landed_cost = fields.Many2One(
         'account.landed_cost', "Landed Cost",
-        required=True, select=True, ondelete='CASCADE')
+        required=True, ondelete='CASCADE')
     product = fields.Many2One(
         'product.product', "Product", required=True, ondelete='CASCADE')
 
@@ -571,8 +575,8 @@
 
 class InvoiceLine(metaclass=PoolMeta):
     __name__ = 'account.invoice.line'
-    landed_cost = fields.Many2One('account.landed_cost', 'Landed Cost',
-        readonly=True, select=True,
+    landed_cost = fields.Many2One(
+        'account.landed_cost', "Landed Cost", readonly=True,
         states={
             'invisible': ~Eval('landed_cost'),
             })

Reply via email to