1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#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):
'''
Define a binary field (``str``).
'''
_type = 'binary'
@staticmethod
def get(cursor, user, ids, model, name, values=None, context=None):
'''
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
:param values: a dictionary with the read values
:param context: the context
:return: a dictionary with ids as key and values as value
'''
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
|