Inventree Python API:如何列出所有库存位置
有关我们使用 YAML 配置文件创建 api 对象的方法,请参见我们之前的文章InventreePython API:使用 YAML 配置的最小 API 连接示例!
inventree_list_stock_locations.py
from inventree.stock import StockLocation
all_stock_locations = StockLocation.list(api)
# 按名称分类的零件类别字典
# (例如 'OpAmps')
stock_locations_by_name = {
category["name"]: category
for category in all_stock_locations
}
# 按公钥分类的零件类别字典(例如 7)
part_locations_by_pk = {
category.pk: category
for category in all_stock_locations
}
# 按层次路径分类的零件类别字典
# (例如 'Office/Spart parts box')
stock_locations_by_pathstring = {
category.pathstring: category
for category in all_stock_locations
}inventree_list_stock_locations.py
from inventree.stock import StockLocation
all_stock_locations = StockLocation.list(api)
# 按名称分类的零件类别字典
# (例如 'OpAmps')
stock_locations_by_name = {
category["name"]: category
for category in all_stock_locations
}
# 按公钥分类的零件类别字典(例如 7)
part_locations_by_pk = {
category.pk: category
for category in all_stock_locations
}
# 按层次路径分类的零件类别字典
# (例如 'Office/Spart parts box')
stock_locations_by_pathstring = {
category.pathstring: category
for category in all_stock_locations
}If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow