You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
just making myself familiar with the API.
i am able to connect to my Inventree server (running in docker on other machine) using dedicated user with only "view" rights to all except Admin.
i can list all stock items with names and locations.
But somehow this simple thing from the documentation does not work in any way:
from inventree.api import InvenTreeAPI
from inventree.part import Part
from inventree.stock import StockItem
SERVER_ADDRESS = 'https://inventree.xxx'
MY_USERNAME = 'python_view'
MY_PASSWORD = 'yyy'
api = InvenTreeAPI(SERVER_ADDRESS, username=MY_USERNAME, password=MY_PASSWORD)
fields = Part.fieldNames(api)
for field in fields:
print(field, '->', Part.fieldInfo(field, api))
it does not crash - just does not yield any result. i dont get why would be that, i have checked the source code - there is defenetely corresponding method for that in base inventree object.
PS: this is the right and only way to see the full ist of fields & properties of the obects or is there some documentation on that topic as well?
from inventree.api import InvenTreeAPI
from inventree.part import Part
from inventree.stock import StockItem
SERVER_ADDRESS = 'https://inventree.xxx'
MY_USERNAME = 'python_view'
MY_PASSWORD = 'xxx'
api = InvenTreeAPI(SERVER_ADDRESS, username=MY_USERNAME, password=MY_PASSWORD)
fields = Part.fieldNames(api)
for field in fields:
print(field, '->', Part.fieldInfo(field, api))
items = StockItem.list(api)
for i_item in items:
i_part=i_item.getPart()
print(i_part.name,'@', 'None' if i_item.getLocation() is None else i_item.getLocation().name)
yields
ThinkSystem 2.5" 600GB 15K SAS 12Gb Hot Swap 512n HDD @ INFR
ThinkSystem 2.5" 600GB 15K SAS 12Gb Hot Swap 512n HDD @ None
ThinkSystem 2.5" 600GB 15K SAS 12Gb Hot Swap 512n HDD @ None
ThinkSystem 2.5" 600GB 15K SAS 12Gb Hot Swap 512n HDD @ INFR
ThinkSystem 2.5" 900GB 15K SAS 12Gb Hot Swap 512e HDD @ INFR
ThinkSystem 2.5" 900GB 15K SAS 12Gb Hot Swap 512e HDD @ INFR
ThinkSystem 2.5" 900GB 15K SAS 12Gb Hot Swap 512e HDD @ INFR
ThinkSystem SR630 V3 @ I/O
which is correct from 2 items with no location one is installed inside other stock item, the other is quarantined.
no other info is returned.
PS: those two moments are a big issue for me by the way - need to find workaround how ot see such items as in stock but not available.
Activity
SchrodingersGat commentedon Nov 1, 2024
@turist79 your code should be working just fine:
yields
Can you perform other operations with the API?
turist79 commentedon Nov 1, 2024
yields
which is correct from 2 items with no location one is installed inside other stock item, the other is quarantined.
no other info is returned.
PS: those two moments are a big issue for me by the way - need to find workaround how ot see such items as in stock but not available.
turist79 commentedon Nov 6, 2024
@SchrodingersGat is there any ideas why no field info is printed out as the result of the code above?
SchrodingersGat commentedon Nov 6, 2024
@turist79 sorry, I'm stumped on this one. Perhaps you could do some debugging, there may be an edge case that we have not considered