Hello,
First of all, kudos for the code. Really.
But...
I'm not sure it's a good idea to change one of the basic premises of the framework - surrogate primary key values.
And that for a very specific application, the like of which I have not yet seen.
As I can see, you are very skilled with coding and that's why I think you should enclose this code in your specific item.
One of the variants of saving PK behavior is to move the story to a unique key.
In both cases I would ask the question,
"How to ensure the uniqueness of the linear combination of your BOM or more simply, what to do when a material with the same BOM specification appears?"
The next question is a bit more theoretical, actually the BOM can be a very large set of participating materials, and then of course the technical question of
operability arises, such as first of all the speed of working with such keys and then the question of accommodation.
I think the author had a completely different idea of using this type of field.
As I already wrote, I also wanted to make something similar to the SELECT2 control, which leads to a little m:n relationship, but it really didn't occur to me
to further branch relationships by that field.
Anyway very good code.
Greetings.