[FIX] fields: inherited fields should get 'string' from their parent field

Because some parameters of a field may be determined during its setup, we have
to update the corresponding column after the setup, and recompute _all_columns
to make it consistent.
This commit is contained in:
Raphael Collet 2014-10-23 11:14:52 +02:00
parent 3e07eaa308
commit 8db5b84fc1
2 changed files with 8 additions and 1 deletions

View File

@ -319,7 +319,8 @@ class Field(object):
self._free_attrs.append(attr)
setattr(self, attr, value)
if not self.string:
if not self.string and not self.related:
# related fields get their string from their parent field
self.string = name.replace('_', ' ').capitalize()
# determine self.default and cls._defaults in a consistent way

View File

@ -2980,6 +2980,12 @@ class BaseModel(object):
if not partial:
raise
# update columns (fields may have changed), and column_infos
for name, field in self._fields.iteritems():
if field.store:
self._columns[name] = field.to_column()
self._inherits_reload()
# group fields by compute to determine field.computed_fields
fields_by_compute = defaultdict(list)
for field in self._fields.itervalues():