Skip to main content

Python interface for InvenTree inventory management system

Project description

PyPi version Build Status

InvenTree Python Interface

Python library for communication with the InvenTree parts management system using the integrated REST API.

This library provides a class-based interface for interacting with the database. Each database table is represented as a class object which provides features analogous to the REST CRUD endpoints (Create, Retrieve, Update, Destroy).

Installation

The InvenTree python library can be easily installed using PIP:

pip install inventree

Example Usage

Very little code is required to start using the Python InvenTree interface.

A minimal example to list all the BOM items required to make a Part is as follows:

from inventree.api import InvenTreeAPI
from inventree.part import Part, BomItem
from inventree.company import SupplierPart

MY_USERNAME = 'not_my_real_username'
MY_PASSWORD = 'not_my_real_password'

api = InvenTreeAPI('http://127.0.0.1:8000/api/', username=MY_USERNAME, password=MY_PASSWORD)

# Access a single part, and get its BOM items directly
part = Part(api, pk=10)
bom_items = part.get_bom_items()

# Alternatively, BOM items can be requested directly from the database
bom_items = BomItem.list(api, part=10)

# Each request is returned as a class object which can be queried further
# Extract all pricing information available for each supplier part for each BOM Item
for item in bom_items:
    supplier_part = SupplierPart.list(api, part=item['sub_part'])

    for part in supplier_parts:
        price_breaks = part.get_price_breaks()
        
        for pb in price_break:
            print(' - ${price} @ {q}'.format(price=pb['cost'], q=pb['quantity']))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inventree-0.0.5.tar.gz (8.2 kB view details)

Uploaded Source

File details

Details for the file inventree-0.0.5.tar.gz.

File metadata

  • Download URL: inventree-0.0.5.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

File hashes

Hashes for inventree-0.0.5.tar.gz
Algorithm Hash digest
SHA256 2ee0d97cfc0c6f46228ce40abd2a6e8e3760d19ec0cbfe94ac98a48dac12c610
MD5 3800d2dfe3613a12ce3f39b8fada4392
BLAKE2b-256 a8d4776921bea88a4261a4e622f51287211b9744351765f3600693300b5b19e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page