changeset ed7fc174f8bf in modules/stock:6.2
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=ed7fc174f8bf
description:
        Use select to True on create_date

        If the index is created only in __register__ then it is dropped before 
being
        created again.

        issue11197
        review389881002
        (grafted from c994fc728bf3ce1530eebf8fea14960960456d3c)
diffstat:

 inventory.py |   4 +---
 move.py      |   4 +---
 shipment.py  |  24 +++++-------------------
 3 files changed, 7 insertions(+), 25 deletions(-)

diffs (139 lines):

diff -r 2e48f4cfc86a -r ed7fc174f8bf inventory.py
--- a/inventory.py      Sat Jan 15 16:23:41 2022 +0100
+++ b/inventory.py      Thu Feb 03 22:29:08 2022 +0100
@@ -72,6 +72,7 @@
     @classmethod
     def __setup__(cls):
         super(Inventory, cls).__setup__()
+        cls.create_date.select = True
         cls._order.insert(0, ('date', 'DESC'))
         cls._transitions |= set((
                 ('draft', 'done'),
@@ -104,9 +105,6 @@
         table = cls.__table_handler__(module_name)
         sql_table = cls.__table__()
 
-        # Add index on create_date
-        table.index_action('create_date', action='add')
-
         # Migration from 5.4: remove lost_found
         table.not_null_action('lost_found', 'remove')
 
diff -r 2e48f4cfc86a -r ed7fc174f8bf move.py
--- a/move.py   Sat Jan 15 16:23:41 2022 +0100
+++ b/move.py   Thu Feb 03 22:29:08 2022 +0100
@@ -297,6 +297,7 @@
     @classmethod
     def __setup__(cls):
         super(Move, cls).__setup__()
+        cls.create_date.select = True
         cls.product.domain = [
             If(Bool(Eval('product_uom_category'))
                 & ~Eval('state').in_(['done', 'cancelled']),
@@ -365,9 +366,6 @@
         super(Move, cls).__register__(module_name)
         table = cls.__table_handler__(module_name)
 
-        # Add index on create_date
-        table.index_action('create_date', action='add')
-
         # Index for period join in compute_quantities_query
         table.index_action([
                 Coalesce(sql_table.effective_date,
diff -r 2e48f4cfc86a -r ed7fc174f8bf shipment.py
--- a/shipment.py       Sat Jan 15 16:23:41 2022 +0100
+++ b/shipment.py       Thu Feb 03 22:29:08 2022 +0100
@@ -249,6 +249,7 @@
     @classmethod
     def __setup__(cls):
         super(ShipmentIn, cls).__setup__()
+        cls.create_date.select = True
         cls._order = [
             ('id', 'DESC'),
             ]
@@ -290,10 +291,6 @@
 
         super(ShipmentIn, cls).__register__(module_name)
 
-        # Add index on create_date
-        table = cls.__table_handler__(module_name)
-        table.index_action('create_date', action='add')
-
         # Migration from 5.6: rename state cancel to cancelled
         cursor.execute(*sql_table.update(
                 [sql_table.state], ['cancelled'],
@@ -661,6 +658,7 @@
     @classmethod
     def __setup__(cls):
         super(ShipmentInReturn, cls).__setup__()
+        cls.create_date.select = True
         cls._order = [
             ('effective_date', 'ASC NULLS LAST'),
             ('id', 'ASC'),
@@ -720,10 +718,6 @@
 
         super(ShipmentInReturn, cls).__register__(module_name)
 
-        # Add index on create_date
-        table = cls.__table_handler__(module_name)
-        table.index_action('create_date', action='add')
-
         # Migration from 5.6: rename state cancel to cancelled
         cursor.execute(*sql_table.update(
                 [sql_table.state], ['cancelled'],
@@ -1049,6 +1043,7 @@
     @classmethod
     def __setup__(cls):
         super(ShipmentOut, cls).__setup__()
+        cls.create_date.select = True
         cls._order = [
             ('effective_date', 'ASC NULLS LAST'),
             ('id', 'ASC'),
@@ -1139,9 +1134,6 @@
 
         super(ShipmentOut, cls).__register__(module_name)
 
-        # Add index on create_date
-        table.index_action('create_date', action='add')
-
         # Migration from 5.6: rename state cancel to cancelled
         cursor.execute(*sql_table.update(
                 [sql_table.state], ['cancelled'],
@@ -1702,6 +1694,7 @@
     @classmethod
     def __setup__(cls):
         super(ShipmentOutReturn, cls).__setup__()
+        cls.create_date.select = True
         cls._order = [
             ('effective_date', 'ASC NULLS LAST'),
             ('id', 'ASC'),
@@ -1745,10 +1738,6 @@
 
         super(ShipmentOutReturn, cls).__register__(module_name)
 
-        # Add index on create_date
-        table = cls.__table_handler__(module_name)
-        table.index_action('create_date', action='add')
-
         # Migration from 5.6: rename state cancel to cancelled
         cursor.execute(*sql_table.update(
                 [sql_table.state], ['cancelled'],
@@ -2176,6 +2165,7 @@
     @classmethod
     def __setup__(cls):
         super(ShipmentInternal, cls).__setup__()
+        cls.create_date.select = True
         cls._order = [
             ('effective_date', 'ASC NULLS LAST'),
             ('id', 'ASC'),
@@ -2262,10 +2252,6 @@
                 where=(sql_table.planned_start_date == Null)
                 & (sql_table.planned_date != Null)))
 
-        # Add index on create_date
-        table = cls.__table_handler__(module_name)
-        table.index_action('create_date', action='add')
-
         # Migration from 5.6: rename state cancel to cancelled
         cursor.execute(*sql_table.update(
                 [sql_table.state], ['cancelled'],

Reply via email to