Files
tryton/trytond/model/fields/binary.py
T

34 lines
1.0 KiB
Python
Raw Normal View History

2009-02-03 18:58:25 +01:00
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.model.fields.field import Field
class Binary(Field):
2009-03-01 13:37:31 +01:00
'''
2009-09-13 15:37:11 +02:00
Define a binary field (``str``).
2009-03-01 13:37:31 +01:00
'''
2009-02-03 18:58:25 +01:00
_type = 'binary'
def get(self, cursor, user, ids, model, name, values=None, context=None):
2009-03-01 13:37:31 +01:00
'''
Convert the binary value into ``str``
:param cursor: the database cursor
:param user: the user id
:param ids: a list of ids
:param model: a string with the name of the model
:param name: a string with the name of the field
2009-09-13 15:37:11 +02:00
:param values: a dictionary with the read values
2009-03-01 13:37:31 +01:00
:param context: the context
:return: a dictionary with ids as key and values as value
'''
2009-02-03 18:58:25 +01:00
if values is None:
values = {}
res = {}
for i in values:
res[i['id']] = i[name] and str(i[name]) or None
for i in ids:
res.setdefault(i, None)
return res