Browse Source

Avoid display duplicated nodes

pull/106/head
Andrea 8 years ago
parent
commit
27cb5c9511
  1. 12
      bi_view_editor/models/ir_model.py

12
bi_view_editor/models/ir_model.py

@ -221,10 +221,22 @@ class IrModel(models.Model):
join_nodes.append(field) join_nodes.append(field)
return join_nodes return join_nodes
def remove_duplicate_nodes(join_nodes):
seen = set()
nodes_list = []
for node in join_nodes:
node_tuple = tuple(node.items())
if node_tuple not in seen:
seen.add(node_tuple)
nodes_list.append(node)
return nodes_list
model_ids = _get_model_ids(field_data) model_ids = _get_model_ids(field_data)
keys = [(field['table_alias'], field['id']) keys = [(field['table_alias'], field['id'])
for field in field_data if field.get('join_node', -1) != -1] for field in field_data if field.get('join_node', -1) != -1]
join_nodes = _get_join_nodes_dict(model_ids, new_field) join_nodes = _get_join_nodes_dict(model_ids, new_field)
join_nodes = remove_duplicate_nodes(join_nodes)
return filter( return filter(
lambda x: 'id' not in x or lambda x: 'id' not in x or
(x['table_alias'], x['id']) not in keys, join_nodes) (x['table_alias'], x['id']) not in keys, join_nodes)

Loading…
Cancel
Save