lims_interface: add 'rec_name' for rows in Compilation data

This commit is contained in:
Mario Puntin 2020-03-30 21:33:58 -03:00
parent 4f0babf89e
commit cd30ac5eb1
1 changed files with 8 additions and 0 deletions

View File

@ -298,6 +298,10 @@ class Data(sequence_ordered(), ModelSQL, ModelView):
return Target.read(target_ids, fields)
def add_related(field_name, rows, targets):
'''
Adds 'id' and 'rec_name' of many2one/related_model fields
Also adds 'rec_name' for the rows
'''
key = field_name + '.'
for row in rows:
value = row[field_name]
@ -305,8 +309,12 @@ class Data(sequence_ordered(), ModelSQL, ModelView):
value = int(value.split(',', 1)[1])
if value is not None and value >= 0:
row[key] = targets[value]
if 'rec_name' in targets[value]:
row['rec_name'] = targets[value]['rec_name']
else:
row[key] = None
if 'rec_name' not in row:
row['rec_name'] = str(row['id'])
cursor = Transaction().connection.cursor()
cursor.execute(*sql_table.select(where=sql_table.id.in_(ids)))