inventree / inventree-python

Python library for communication with inventree via API
https://docs.inventree.org/en/latest/api/python/python/
MIT License
26 stars 34 forks source link

Add support to edit part base properties #137

Closed axibo-reiner closed 1 year ago

axibo-reiner commented 1 year ago

Edit the base properties of a part, such as minimum-stock.

SchrodingersGat commented 1 year ago

@axibo-reiner this is all achievable right now. I realize there are no examples in the documentation about this. I'll add the following example which you can use for now as a starting point:

from inventree.api import InvenTreeAPI
from inventree.part import Part

api = InvenTreeAPI(host='http://localhost:8000', username='admin', password='inventree')

# Retrieve part instance
part = Part(api, pk=1)

# Update specified part parameters
part.save(data={
    "description": "New part description",
    "minimum_stock": 250,
})

# Reload data from remote server
part.reload()

print("Part Name:", part.name)
print("Description:", part.description)
print("Minimum stock:", part.minimum_stock)
SchrodingersGat commented 1 year ago

Ref: https://github.com/inventree/inventree-docs/pull/355