Skip to content


BOM Generation

The bill of materials is an essential part of the documentation that needs to be sent to the factory. A simple csv export is OK to be important into SMT machines. But for human readable documentation it might not be sufficient. Additional information is needed. The Inventree report system allows to generate BOM well formatted BOM reports.

A simple example

The following picture shows a simple example for a PCB with just three components from two different parts.

BOM example BOM example

This example has been created using the following html template:

{% extends "report/inventree_report_base.html" %}

{% load i18n %}
{% load report %}
{% load inventree_extras %}

{% block page_margin %}
margin-left: 2cm;
margin-right: 1cm;
margin-top: 4cm;
{% endblock %}

{% block bottom_left %}
content: "v{{report_revision}} - {{ date.isoformat }}";
{% endblock %}

{% block bottom_center %}
content: "InvenTree v{% inventree_version %}";
{% endblock %}

{% block style %}
.header-left {
    text-align: left;
    float: left;
table {
    border: 1px solid #eee;
    border-radius: 3px;
    border-collapse: collapse;
    width: 100%;
    font-size: 80%;
table td {
    border: 1px solid #eee;
{% endblock %}

{% block header_content %}
    <div class='header-left'>
        <h3>{% trans "Bill of Materials" %}</h3>
{% endblock %}

{% block page_content %}
  <tr> <td>Board</td><td>{{ part.IPN }}</td>  </tr>
  <tr> <td>Description</td><td>{{ part.description }}</td> </tr>
  <tr> <td>User</td><td>{{ user }}</td> </tr>
  <tr> <td>Date</td><td>{{ date }}</td> </tr>
  <tr> <td>Number of different components (codes)</td><td>{{ bom_items.count }}</td> </tr>
<table class='table table-striped table-condensed'>
            <th>{% trans "IPN" %}</th>
            <th>{% trans "MPN" %}</th>
            <th>{% trans "Manufacturer" %}</th>
            <th>{% trans "Quantity" %}</th>
            <th>{% trans "Reference" %}</th>
            <th>{% trans "Substitute" %}</th>
        {% for line in bom_items.all %}
            <td>{{ line.sub_part.IPN }}</td>
            <td>{{ }}</td>
              {% for manf in line.sub_part.manufacturer_parts.all %}
               {{ }}
               {% endfor %}
          <td>{% decimal line.quantity %}</td>
          <td>{{ line.reference }}</td>
              {% for sub in line.substitutes.all %}
            {{ sub.part.IPN }}<br>
            {% endfor %}
        {% endfor %}

{% endblock %}

Context variables

Variable Description
bom_items Query set that contains all BOM items
bom_items...sub_part One component of the BOM
bom_items...quantity Number of parts
bom_items...reference Reference designators of the part
bom_items...substitutes Query set that contains substitutes of the part if any exist in the BOM

Last update: April 26, 2022