I am creating a web tool to manage bills of materials (BOM).
I managed to get some nice presentation of BOMs using django
with js-tree
but now I would like to put all of this in a database.
My trees look like this:
- Root Part (ie Product A)
- PartA - Qty: 1
- PartB - Qty: 1
- PartC - Qty: 1
- Part D - Qty: 4
- Part E - Qty: 1
- Part F - Qty: 2
...
The problem is that a same part can be present in different products, or in different subassembly (think of a screw for example).
I would like to be able to reuse an existing node (and its children) in an other tree (for example I could have a Product B that also include Part E (and thus Part F)). If I am updating a node (ie Part E) the change should appear in every trees where it is used.
django-mptt
seems a good candidate but unfortunately a node can only have one parent.
There is a TreeManyToManyField
but nothing in the documentation about it, I am not sure if it could help me.
I could create the Part
as a regular model and have a second model Bom Structure
to create the trees, each instance being link to a Part
but I can't see how it will keep the children of a part.
How does people manage this issue usually?