-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inventree Project Code API bugs with both api and api endpoints #246
Comments
We can certainly implement this, and return a
All "foreign key" fields in the API use the primary key to lookup, that is not going to change. You need to know ahead of time what the primary key value is |
Yeah for some reason when specifically searching via the project code it throws an error and only wants to search primary keys. I'm currently trying to find a way around it but I'm not sure if it is a skill issue on my part or not.
Checking the api endpoint it shows My alternate plan was to search the project code endpoint for the project code object, return the primary key and then filter by the primary key but that still runs into the error of
To be clear, project_code is the only field I've had this issue with, others seem to work just fine. I'm trying to interlink my app with the inventree app and I need a way to retrieve purchase orders linked to a specific project, if I need to make two requests: one to find the primary key and one to then retrieve the purchase orders, that's fine. But it looks like I can't search project codes like I figured I'd be able to? Is there currently a way to find the primary key easily from the EDIT:
Yeah ran into this myself on my own project, had to completely change how all my models worked because most of the additional apps I was using only played nicely with primary key lookups, even though I would have much preferred to lookup a different field. EDIT: Just realised worst comes to worst I can just return a list of length one via |
just trying to understand this issue: is there an actual bug and what would be the expected fix or can we close this? |
This fix is ideal and to be clearer, the error I received when trying to do this was:
|
Is it possible for For some context, I won't be creating every single one of the project codes myself and rather some will be made to cover some partially legacy jobs. I won't have the primary keys for these, at least not initially, so I'll need to fetch it. There is some chance that this causes some clunky overlap but project codes only have a generic search and not a field restricted search. There would also be some usefulness in being able to search specifically descriptions for similar projects in the future, externally. |
@Eddalius FYI I have moved this issue from |
You can use the |
Please verify that this bug has NOT been raised before.
Describe the bug*
Unsure if this issue should be raised here or within the python app github but seemingly applies to an issue with both, so I'll raise it here.
When you attempt to use the python API to search the endpoints of the inventree instance for project codes, it errors if it is not a project code that exists. The project code is referenced by the primary key and not the project code itself, so if you were to search the purchase orders for all orders with a project code of 14, it'd error unless a project code had a primary key of 14 (which might not align with the naming scheme of your project codes).
I've checked the api endpoints and can see that the project code information is all there but cannot figure out a way to search it that doesn't throw an error.
Two parts to this bug:
Searching via
purchase_order_list = PurchaseOrder.list(api, project_code=14)
will return an error if a project code with the primary key of 14 does not existSecondly, it'll return the wrong project code if a primary key of 14 exists and isn't the correct project code.
Steps to Reproduce
api = InvenTreeAPI(http://aninventree.instance.local:80, username=' ', password=' ')
, with all relevant information obscured)purchase_order_list = PurchaseOrder.list(api, has_project_code=True, project_code=14)
returnsproject_code":["Select a valid choice. That choice is not one of the available choices.
)purchase_order_list = PurchaseOrder.list(api, has_project_code=True, project_code=5)
, succeeded as my project code has a primary key of 5, can be seen via the api endpoint)Expected behaviour
I expect to receive an empty list when searching for project codes and none are found. I also expect to be searching the project_code field itself when searching
project_code=14
rather than the foreign key field for the primary key of the project code instead.Deployment Method
Version Information
Inventree version: 0.16.4
API version: 232
Please verify if you can reproduce this bug on the demo site.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: