From 2d37d0ac214f65737d02e98f15cf64f965dbd273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 6 Mar 2009 00:45:43 +0100 Subject: [PATCH] Use TableHandler to create index on location --- location.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/location.py b/location.py index fd951adec7..4b33a1ae2f 100644 --- a/location.py +++ b/location.py @@ -3,6 +3,7 @@ "Wharehouse" from trytond.model import ModelView, ModelSQL, fields from trytond.wizard import Wizard +from trytond.backend import TableHandler import datetime STATES = { @@ -84,13 +85,8 @@ class Location(ModelSQL, ModelView): def init(self, cursor, module_name): super(Location, self).init(cursor, module_name) - cursor.execute('SELECT indexname FROM pg_indexes ' \ - 'WHERE indexname = ' \ - '\'stock_location_left_right_index\'') - if not cursor.rowcount: - cursor.execute('CREATE INDEX ' \ - 'stock_location_left_right_index ' \ - 'ON stock_location ("left", "right")') + table = TableHandler(cursor, self._table, self._name, module_name) + table.index_action(['left', 'right'], 'add') def check_type_for_moves(self, cursor, user, ids): """ Check locations with moves have types compatible with moves. """