From 0c205db899020d477dad7b789bc31963da0c92b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 9 Feb 2009 23:23:14 +0100 Subject: [PATCH] Add indexes on left, right of location --- location.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/location.py b/location.py index 4b82b8ad5c..96e63d5ca9 100644 --- a/location.py +++ b/location.py @@ -34,8 +34,8 @@ class Location(OSV): ], 'Location type', states=STATES) parent = fields.Many2One("stock.location", "Parent", select=1, left="left", right="right") - left = fields.Integer('Left', required=True) - right = fields.Integer('Right', required=True) + left = fields.Integer('Left', required=True, select=1) + right = fields.Integer('Right', required=True, select=1) childs = fields.One2Many("stock.location", "parent", "Childs") input_location = fields.Many2One( "stock.location", "Input", states={ @@ -81,6 +81,17 @@ class Location(OSV): 'cannot be changed to a type that does not support moves.', }) + 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")') + def check_type_for_moves(self, cursor, user, ids): """ Check locations with moves have types compatible with moves. """ invalid_move_types = ['warehouse', 'view']