Electronics inventory system V2 – Inventree

Any person working with electronics, either for hobby or professionally will have a large assortment of components and parts laying around.
I’d encourage anyone that will keep any kind of inventory of parts to invest some time in creating a system to keep track of the components you have, the location, and the ability to attach information and documents.

I was already using Partkeepr as described in a previous post

I switched over to Inventree because Partkeepr has gone stale and is not being maintained anymore.

Partkeepr to Inventree data transfer & problems

There is a pluging/script to transfer the data from partkeepr to inventree, sadly this one is outdated and not maintained at the time im writing this.

Luckily Frank Steinberg provided a great python script I was able to use to transfer all my data from Partkeepr to Inventree.

Unfortunatly it did not work on the first try, but with some modification I was able to get it to work for me.

401 Unauthorized

My main issue from the start was the program kept crashing without a clear reason. by adding a printline I saw kept getting a 401 response when requesting data from partkeepr. I had to put in my credentials at the correct locations for the HTTP requests. only putting the credentials into the url at the top of the script did not work for me.

Here you can find more info about the HTTP request package and how to use it.

def getFromPartkeepr(url, base, auth):

    full_url = f'{base}{url}?itemsPerPage=100000'
    r = requests.get(full_url, auth=('admin', 'admin'))
    print(r)
    if (r.status_code == 200):
        return r.json()["hydra:member"]
    return None



def getImageFromPartkeepr(url, base, auth, filename="image"):

    full_url = f'{base}{url}/getImage'
    r = requests.get(full_url, auth=('admin', 'admin'), stream=True)

    if (r.status_code == 200):
        r.raw.decode_content = True
        tmp = tempfile.NamedTemporaryFile(delete=False, suffix="f-%s" % (filename))
        shutil.copyfileobj(r.raw, tmp)
        return tmp.name
    return None


def getFileFromPartkeepr(url, base, auth, filename="file"):

    full_url = f'{base}{url}/getFile'
    r = requests.get(full_url, auth=('admin', 'admin'), stream=True)

    if (r.status_code == 200):
        r.raw.decode_content = True
        path = f'/tmp/{filename}'
        f = open(path, 'wb')
        shutil.copyfileobj(r.raw, f)
        f.close()
        return path
    return None

Keyerror: 18

I kept getting a keyerror because my root catagory did not have a parent, fixed this by adding a exception catch to ignore the lack of a parrent.

category_map = {} # mapped by @id
    for category in categories:
        id = int(category['@id'].rpartition("/")[2])
        if category["parent"]:
            parent_id = int(category["parent"]["@id"].rpartition("/")[2])
            try:
                parent_pk = category_map[parent_id]
            except KeyError:
                pass
        else:
            parent_pk = None
        if verbose:
            print(f'create PartCategory "{category["name"]}", parent:{parent_pk}')
        icategory = create(PartCategory, inventree, {
            'name': category["name"],
            'description': category["description"],
            'parent': parent_pk,
            })
        category_map[id] = icategory.pk

Features

InvenTree is an open-source inventory management system which provides intuitive parts management and stock control. A wide range of features makes InvenTree the perfect choice for businesses and hobbyists alike. InvenTree is designed to be extensible, and provides multiple options for integration with external applications or addition of custom plugins.

Showcase

Parts dashboard:

Stock locations

Storage places

I currently use 3 storage methods.

  • organizing drawers
  • Tic Tac boxes
  • Jewelry boxes for small items

ESD safety

To protect some electronic components from ESD damage I try to keep in mind how I store them. Although not as often as I should..

To properly protect against ESD you need a storage box or bag that is below a certain surface resistance to dissipate the charge.

  • <10^3Ω = shielding
  • <10^4Ω = conductive
  • 10^4Ω -> 10^11Ω = static disipative
  • >10^11Ω = insulative (not ESD safe)

Source: ANSI/ESD S541
these numbers vary a bit between sources, ANSI,ISO,IEC

The Tic Tac boxes I use are made of PP (polypropylene).
PP has a surface resistance of 10^13 and does not meet ESD requirements because of this.
I put ESD-sensitive parts in an extra anti-static bag or stick them on esd foam, and then put it in the tic-tac box for easy storage and cataloging.

Author: Robin

I'm Robin Peeten, a science enthusiast specialized in electronics and IT. By working on a lot of personal projects I gathered a lot of knowledge and practical experience with the aforementioned subjects and more. Able to design and repair electronic and electrical systems, and work as a sysadmin for professional computer systems and server gear. Take a look at my project list for examples.

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Appliance - Powered by TurnKey Linux