Added filtered file selection feature on binary field.Usage: fields.binary('Upload a file',filters=['*.zip','a*.jpg','*.doc'])

bzr revid: jvo@tinyerp.com-20080916073123-xjbylq32uci2yr2d
This commit is contained in:
Jay Vora 2008-09-16 13:01:23 +05:30
parent 7b16d23aab
commit 02104cd18b
2 changed files with 8 additions and 4 deletions

View File

@ -204,7 +204,11 @@ class binary(_column):
_symbol_set = (_symbol_c, _symbol_f)
_classic_read = False
def __init__(self, string='unknown', filters=None, **args):
_column.__init__(self, string=string, **args)
self.filters = filters
def get_memory(self, cr, obj, ids, name, user=None, context=None, values=None):
if not context:
context = {}
@ -220,7 +224,7 @@ class binary(_column):
break
res.setdefault(i, val)
if context.get('get_binary_size', True):
res[i] = tools.human_size(val)
res[i] = tools.human_size(val)
return res
@ -615,7 +619,7 @@ class function(_column):
res = self._fnct(obj, cr, user, ids, name, self._arg, context)
else:
res = self._fnct(cr, obj._table, ids, name, self._arg, context)
if self._type == 'binary' and context.get('get_binary_size', False):
# convert the data returned by the function with the size of that data...
res = dict(map(lambda (x, y): (x, tools.human_size(len(y))), res.items()))

View File

@ -686,7 +686,7 @@ class orm_template(object):
if not read_access:
res[f]['readonly'] = True
res[f]['states'] = {}
for arg in ('digits', 'invisible'):
for arg in ('digits', 'invisible','filters'):
if hasattr(self._columns[f], arg) \
and getattr(self._columns[f], arg):
res[f][arg] = getattr(self._columns[f], arg)