Fix test to translate read field

The test was using the field name instead of the field instance.
It is better to keep the usual convention of using fname for name and field for
the instance.

issue6208
review33011002
This commit is contained in:
Cédric Krier committed 2017-01-25 23:30:23 +01:00
1 parent c1b8ee10c6
commit 811cbb2ad4
1 file changed
+8 -6
+8 -6
View File
@@ -725,15 +725,17 @@ class ModelSQL(ModelStorage):
for column in columns:
# Split the output name to remove SQLite type detection
field = column.output_name.split()[0]
if field == '_timestamp':
fname = column.output_name.split()[0]
if fname == '_timestamp':
continue
if (getattr(cls._fields[field], 'translate', False)
field = cls._fields[fname]
if (getattr(field, 'translate', False)
and not hasattr(field, 'get')):
translations = Translation.get_ids(cls.__name__ + ',' + field,
'model', Transaction().language, ids)
translations = Translation.get_ids(
cls.__name__ + ',' + fname, 'model',
Transaction().language, ids)
for row in result:
row[field] = translations.get(row['id']) or row[field]
row[fname] = translations.get(row['id']) or row[fname]
# all fields for which there is a get attribute
getter_fields = [f for f in