[IMP] have ir_fields_converter.to_field accept either a type or a string-representing-a-type as input

bzr revid: xmo@openerp.com-20130927142856-lnrboxzgpd3wzqem
This commit is contained in:
Xavier Morel
2013-09-27 16:28:56 +02:00
parent a4746b22c2
commit 3295203a66
+5 -2
View File
@@ -133,14 +133,17 @@ class ir_fields_converter(orm.Model):
:param column: column object to generate a value for
:type column: :class:`fields._column`
:param type fromtype: type to convert to something fitting for ``column``
:param fromtype: type to convert to something fitting for ``column``
:type fromtype: type | str
:param context: openerp request context
:return: a function (fromtype -> column.write_type), if a converter is found
:rtype: Callable | None
"""
assert isinstance(fromtype, (type, str))
# FIXME: return None
typename = fromtype.__name__ if isinstance(fromtype, type) else fromtype
converter = getattr(
self, '_%s_to_%s' % (fromtype.__name__, column._type), None)
self, '_%s_to_%s' % (typename, column._type), None)
if not converter: return None
return functools.partial(