Giter Site home page Giter Site logo

inventree-python's Introduction

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).

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_object import Part, BomItem, 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']))

inventree-python's People

Contributors

rco3 avatar schrodingersgat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.