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
This commit is contained in:
Cédric Krier
2022-02-03 22:29:08 +01:00
parent b13b3c7b4e
commit f72cdeb5de
3 changed files with 7 additions and 25 deletions
+1 -3
View File
@@ -72,6 +72,7 @@ class Inventory(Workflow, ModelSQL, ModelView):
@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 @@ class Inventory(Workflow, ModelSQL, ModelView):
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')
+1 -3
View File
@@ -296,6 +296,7 @@ class Move(Workflow, ModelSQL, ModelView):
@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']),
@@ -364,9 +365,6 @@ class Move(Workflow, ModelSQL, ModelView):
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,
+5 -19
View File
@@ -249,6 +249,7 @@ class ShipmentIn(ShipmentMixin, Workflow, ModelSQL, ModelView):
@classmethod
def __setup__(cls):
super(ShipmentIn, cls).__setup__()
cls.create_date.select = True
cls._order = [
('id', 'DESC'),
]
@@ -290,10 +291,6 @@ class ShipmentIn(ShipmentMixin, Workflow, ModelSQL, ModelView):
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'],
@@ -667,6 +664,7 @@ class ShipmentInReturn(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
@classmethod
def __setup__(cls):
super(ShipmentInReturn, cls).__setup__()
cls.create_date.select = True
cls._order = [
('effective_date', 'ASC NULLS LAST'),
('id', 'ASC'),
@@ -726,10 +724,6 @@ class ShipmentInReturn(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
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'],
@@ -1059,6 +1053,7 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
@classmethod
def __setup__(cls):
super(ShipmentOut, cls).__setup__()
cls.create_date.select = True
cls._order = [
('effective_date', 'ASC NULLS LAST'),
('id', 'ASC'),
@@ -1149,9 +1144,6 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
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'],
@@ -1716,6 +1708,7 @@ class ShipmentOutReturn(ShipmentMixin, Workflow, ModelSQL, ModelView):
@classmethod
def __setup__(cls):
super(ShipmentOutReturn, cls).__setup__()
cls.create_date.select = True
cls._order = [
('effective_date', 'ASC NULLS LAST'),
('id', 'ASC'),
@@ -1759,10 +1752,6 @@ class ShipmentOutReturn(ShipmentMixin, Workflow, ModelSQL, ModelView):
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'],
@@ -2196,6 +2185,7 @@ class ShipmentInternal(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
@classmethod
def __setup__(cls):
super(ShipmentInternal, cls).__setup__()
cls.create_date.select = True
cls._order = [
('effective_date', 'ASC NULLS LAST'),
('id', 'ASC'),
@@ -2282,10 +2272,6 @@ class ShipmentInternal(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
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'],