inventree / InvenTree

Open Source Inventory Management System
https://docs.inventree.org
MIT License
4.33k stars 784 forks source link

[Importer] Allow to reference importing rows #8203

Open wolflu05 opened 1 month ago

wolflu05 commented 1 month ago

Please verify that this feature request has NOT been suggested before.

Problem statement

When importing a dataset it is not possible to reference other rows from the current dataset. This is required to import a deeply nested category tree, location tree, ... (ref: https://github.com/inventree/InvenTree/issues/8166#issuecomment-2376735397)

Suggested solution

Allow to select an extra column for the primary key of the dataset lines. Then this column can be used to lookup rows when other rows reference e.g. *1 (where the * means look for a row in the current dataset with this id.).

Example:

pk,name,parent
1,Electronic Parts1,
2,Passives,*1
3,Resistors,*2
4,Capacitors,*2
5,IC,*1
6,Mechanic Parts,

This then can be used to build a graph of data and then start by importing the root node first, then the Childs of the root node, ...

Describe alternatives you've considered

Import categories or locations "level by level"

Examples of other systems

No response

Do you want to develop this?

SchrodingersGat commented 1 month ago

We already have a unique "row" number (within the dataset) - we could use this, perhaps?

wolflu05 commented 1 month ago

What column are you referring too? You mean the index of the entry in the csv file? I would argument that this is not a great idea, as then we rely on the order of the lines in the csv table. And the order may change if people manually modify the file.

SchrodingersGat commented 1 month ago

Fair point!