From d3b3cd41f2f6dfc6a6d52a6a464506fcc16716c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 28 Sep 2009 11:58:52 +0200 Subject: [PATCH] Add test is column_name is in _columns when testing field type for issue1194 add_raw_column is used in _update_history_table and column_name can any more exist or not yet instanciate in the Model --- trytond/backend/sqlite/table.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/trytond/backend/sqlite/table.py b/trytond/backend/sqlite/table.py index 6c29e4cce8..13b378031e 100644 --- a/trytond/backend/sqlite/table.py +++ b/trytond/backend/sqlite/table.py @@ -179,7 +179,9 @@ class TableHandler(TableHandlerInterface): column_type = column_type[1] default = '' from trytond.model import fields - if isinstance(self._model._columns[column_name], (fields.Integer, fields.Float)): + if column_name in self._model._columns and \ + isinstance(self._model._columns[column_name], + (fields.Integer, fields.Float)): default = ' DEFAULT 0' self.cursor.execute(('ALTER TABLE "%s" ADD COLUMN "%s" %s' + default) % (self.table_name, column_name, column_type))