[FIX] reimplement quality selection field API

a size attribute of -1 means the selection field is an int4, even if the selection is a callable

bzr revid: xmo@openerp.com-20110909161623-nab218ea48ucj4qt
This commit is contained in:
Xavier Morel 2011-09-09 18:16:23 +02:00
parent 0d965c2fca
commit 9c83238f18
1 changed files with 2 additions and 1 deletions

View File

@ -517,7 +517,8 @@ def get_pg_type(f, type_override=None):
elif issubclass(field_type, (fields.char, fields.reference)):
return ('varchar', pg_varchar(f.size))
elif issubclass(field_type, fields.selection):
if isinstance(f.selection, list) and isinstance(f.selection[0][0], int):
if (isinstance(f.selection, list) and isinstance(f.selection[0][0], int))\
or getattr(f, 'size', None) == -1:
return ('int4', 'INTEGER')
return ('varchar', pg_varchar(getattr(f, 'size', None)))
elif issubclass(field_type, fields.function):