From 0d965c2fca76a73bc301da6769d34e1360a9e418 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 9 Sep 2011 17:58:48 +0200 Subject: [PATCH] [FIX] if types can be overridden, type-checking against the overriden type instead of the non-overridden instance might be a good idea as well bzr revid: xmo@openerp.com-20110909155848-5no3pvtfugqmhm8q --- openerp/osv/orm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 4c592a53342..92a22a29f9a 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -510,17 +510,17 @@ def get_pg_type(f, type_override=None): if field_type in FIELDS_TO_PGTYPES: return (FIELDS_TO_PGTYPES[field_type], FIELDS_TO_PGTYPES[field_type]) - elif isinstance(f, fields.float): + elif issubclass(field_type, fields.float): if f.digits: return ('numeric', 'NUMERIC') return ('float8', 'DOUBLE PRECISION') - elif isinstance(f, (fields.char, fields.reference)): + elif issubclass(field_type, (fields.char, fields.reference)): return ('varchar', pg_varchar(f.size)) - elif isinstance(f, fields.selection): + elif issubclass(field_type, fields.selection): if isinstance(f.selection, list) and isinstance(f.selection[0][0], int): return ('int4', 'INTEGER') return ('varchar', pg_varchar(getattr(f, 'size', None))) - elif isinstance(f, fields.function): + elif issubclass(field_type, fields.function): if f._type == 'selection': return ('varchar', pg_varchar()) return get_pg_type(f, getattr(fields, f._type))