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 exist
Secondly, it'll return the wrong project code if a primary key of 14 exists and isn't the correct project code.
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)
returns project_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)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.
Inventree version: 0.16.4
API version: 232
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too