Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: BI View Editor

Entity: bve.view

Compute Method: _compute_er_diagram_image

Inputs Method Outputs
  • table_alias
  • model_id
  • model_id.name
  • field_id
  • field_id.field_description
  • description
  • ttype
  • join_node
for bve_view in self:
            graph = pydot.Dot(graph_type="graph")
            table_model_map = {}
            for line in bve_view.field_ids:
                if line.table_alias not in table_model_map:
                    table_alias_node = pydot.Node(
                        line.model_id.name + " " + line.table_alias,
                        style="filled",
                        shape="box",
                        fillcolor="#DDDDDD",
                    )
                    table_model_map[line.table_alias] = table_alias_node
                    graph.add_node(table_model_map[line.table_alias])
                field_node = pydot.Node(
                    line.table_alias + "." + line.field_id.field_description,
                    label=line.description,
                    style="filled",
                    fillcolor="green",
                )
                graph.add_node(field_node)
                graph.add_edge(
                    pydot.Edge(table_model_map[line.table_alias], field_node)
                )
            for line in bve_view.relation_ids:
                field_description = line.field_id.field_description
                table_alias = line.table_alias
                diamond_node = pydot.Node(
                    line.ttype + " " + table_alias + "." + field_description,
                    label=table_alias + "." + field_description,
                    style="filled",
                    shape="diamond",
                    fillcolor="#D2D2FF",
                )
                graph.add_node(diamond_node)
                graph.add_edge(
                    pydot.Edge(
                        table_model_map[table_alias],
                        diamond_node,
                        labelfontcolor="#D2D2FF",
                        color="blue",
                    )
                )
                graph.add_edge(
                    pydot.Edge(
                        diamond_node,
                        table_model_map[line.join_node],
                        labelfontcolor="black",
                        color="blue",
                    )
                )
            try:
                png_base64_image = base64.b64encode(graph.create_png())
                bve_view.er_diagram_image = png_base64_image
            except Exception:
                bve_view.er_diagram_image = False

Back to entity