_symbol_f = lambda x: x and 'True' or 'False'
_symbol_set = (_symbol_c, _symbol_f)
+ def __init__(self, string='unknown', required=False, **args):
+ super(boolean, self).__init__(string=string, required=required, **args)
+ if required:
+ warnings.warn("Making a boolean field `required` has no effect, as NULL values are "
+ "automatically turned into False", PendingDeprecationWarning, stacklevel=2)
+
class integer(_column):
_type = 'integer'
_symbol_c = '%s'
_symbol_set = (_symbol_c, _symbol_f)
_symbol_get = lambda self,x: x or 0
+ def __init__(self, string='unknown', required=False, **args):
+ super(integer, self).__init__(string=string, required=required, **args)
+ if required:
+ warnings.warn("Making an integer field `required` has no effect, as NULL values are "
+ "automatically turned into 0", PendingDeprecationWarning, stacklevel=2)
+
class integer_big(_column):
"""Experimental 64 bit integer column type, currently unused.
_symbol_set = (_symbol_c, _symbol_f)
_symbol_get = lambda self,x: x or 0
+ def __init__(self, string='unknown', required=False, **args):
+ super(integer_big, self).__init__(string=string, required=required, **args)
+ if required:
+ warnings.warn("Making an integer_big field `required` has no effect, as NULL values are "
+ "automatically turned into 0", PendingDeprecationWarning, stacklevel=2)
+
class reference(_column):
_type = 'reference'
_classic_read = False # post-process to handle missing target
_symbol_set = (_symbol_c, _symbol_f)
_symbol_get = lambda self,x: x or 0.0
- def __init__(self, string='unknown', digits=None, digits_compute=None, **args):
- _column.__init__(self, string=string, **args)
+ def __init__(self, string='unknown', digits=None, digits_compute=None, required=False, **args):
+ _column.__init__(self, string=string, required=required, **args)
self.digits = digits
self.digits_compute = digits_compute
+ if required:
+ warnings.warn("Making a float field `required` has no effect, as NULL values are "
+ "automatically turned into 0.0", PendingDeprecationWarning, stacklevel=2)
def digits_change(self, cr):
result = (value, dict_names[value])
if field_type == 'binary':
- if context.get('bin_size', False):
+ if context.get('bin_size'):
# client requests only the size of binary fields
result = get_nice_size(value)
- else:
+ elif not context.get('bin_raw'):
result = sanitize_binary_value(value)
if field_type in ("integer","integer_big") and value > xmlrpclib.MAXINT:
def _field_get2(self, cr, uid, obj, context=None):
if self._relations:
return
+ result = []
obj_name = obj._name
for i in range(len(self._arg)):
f = obj.pool.get(obj_name).fields_get(cr, uid, [self._arg[i]], context=context)[self._arg[i]]
- self._relations.append({
+ result.append({
'object': obj_name,
'type': f['type']
})
if f.get('relation',False):
obj_name = f['relation']
- self._relations[-1]['relation'] = f['relation']
+ result[-1]['relation'] = f['relation']
+ self._relations = result
# ---------------------------------------------------------
# Dummy fields
res['domain'] = field._domain
res['context'] = field._context
+ if isinstance(field, one2many):
+ res['relation_field'] = field._fields_id
+
return res