- JavaScript 89.6%
- Python 10.4%
Boxes are drawn centred on their slot, so the outermost ones stuck out by half a box and got cut off at the left edge. The viewBox origin now makes room for that, and the width accounts for the box instead of the step. The part name also ran into the "+n parts" note; it is clipped shorter now when that note is present. Boxes widened 156 -> 174 px. Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| inventree_bom_viewer | ||
| .gitignore | ||
| MANIFEST.in | ||
| pyproject.toml | ||
| README.md | ||
inventree-bom-viewer
Adds a BOM Tree panel to the detail page of every assembly in InvenTree: the multi-level bill of materials in one view, instead of clicking through one table per level. Quantities are cumulative -- multiplied down through the levels.
Three views, switched in the panel:
- List -- a collapsible outline. Every row links to the part and carries
flags for
consumable,optional, an empty sub-BOM, a depth cut-off or a cycle. - Org chart -- boxes top-down, one colour per top-level branch.
- Mind map -- the same tree branching left to right along curves.
Both charts have a zoom slider and a Sub-assemblies only switch. That switch
matters: a BOM with many single parts per level becomes several thousand pixels
wide as a chart, because every screw claims its own column. Folding the plain
parts away keeps the structure readable; the boxes then show +n parts for what
was folded. It defaults to on for the org chart and off for the mind map.
Requirements
- InvenTree >= 1.0 (developed against 1.4.0, API 511)
- Global setting Enable interface integration (
ENABLE_PLUGINS_INTERFACE) switched on, otherwise no plugin panel is shown anywhere.
The plugin needs no other integration setting: it reads /api/bom/ through the
session the user is already logged in with. There is no custom endpoint.
Install
Admin Center -> Plugins -> Install Plugin, from this git URL. Then activate the plugin and reload the page.
Development notes
The frontend is a hand-written ES module (inventree_bom_viewer/static/BomViewer.js)
using the React and MantineCore globals that InvenTree exposes to plugins.
That avoids a npm/Vite toolchain for what is a single panel. If the panel ever
grows beyond this, switch to the official plugin-creator layout.
The entry point must accept exactly one argument -- InvenTree dispatches on
Function.length, and 0 or 3+ arguments are rejected. Note that default
parameters do not count towards length.