[MERGE] orm,fields: fields.char's argument now all optional (especially @size) + minor cleanup

The size limit on fields.char is entirely cosmetics,
as it makes no difference in performance or size for
PostgreSQL storage. The size only has to be specified
when the field needs to be size-constrained for
business reasons, like fixed-length references, EAN, etc.

bzr revid: odo@openerp.com-20120723172229-vyzrgzhugsd17rao
This commit is contained in:
Olivier Dony
2012-07-23 19:22:29 +02:00
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -49,7 +49,7 @@ import simplejson
_logger = logging.getLogger(__name__)
def _symbol_set(symb):
if symb == None or symb == False:
if symb is None or symb == False:
return None
elif isinstance(symb, unicode):
return symb.encode('utf-8')
@@ -181,8 +181,8 @@ class reference(_column):
class char(_column):
_type = 'char'
def __init__(self, string, size, **args):
_column.__init__(self, string=string, size=size, **args)
def __init__(self, string="unknown", size=None, **args):
_column.__init__(self, string=string, size=size or None, **args)
self._symbol_set = (self._symbol_c, self._symbol_set_char)
# takes a string (encoded in utf8) and returns a string (encoded in utf8)
@@ -191,7 +191,7 @@ class char(_column):
# * we need to remove the "symb==False" from the next line BUT
# for now too many things rely on this broken behavior
# * the symb==None test should be common to all data types
if symb == None or symb == False:
if symb is None or symb == False:
return None
# we need to convert the string to a unicode object to be able
+2 -2
View File
@@ -758,7 +758,7 @@ class BaseModel(object):
'model_id': model_id,
'model': self._name,
'name': k,
'field_description': f.string.replace("'", " "),
'field_description': f.string,
'ttype': f._type,
'relation': f._obj or '',
'view_load': (f.view_load and 1) or 0,
@@ -767,7 +767,7 @@ class BaseModel(object):
'required': (f.required and 1) or 0,
'selectable': (f.selectable and 1) or 0,
'translate': (f.translate and 1) or 0,
'relation_field': (f._type=='one2many' and isinstance(f, fields.one2many)) and f._fields_id or '',
'relation_field': f._fields_id if isinstance(f, fields.one2many) else '',
'serialization_field_id': None,
}
if getattr(f, 'serialization_field', None):