Skip to content

Inventree Project Code API bugs with both api and api endpoints #246

@Eddalius

Description

@Eddalius

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

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 exist

Secondly, it'll return the wrong project code if a primary key of 14 exists and isn't the correct project code.

Steps to Reproduce

  1. Auth with the API (I've been using the python interface for this, specifically: api = InvenTreeAPI(http://aninventree.instance.local:80, username=' ', password=' ') , with all relevant information obscured)
  2. Using the python app, attempt to search for a project code that doesn't exist (will error instead of returning none, odd behaviour, imo: 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.)
  3. Create a project code (done via the web interface, made a project code with the code 14)
  4. Attempt to search project code via the code you setup (same input as step 3, same return as step 3)
  5. Attempt to search project code via primary key of the project code (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

  • Docker
  • Package
  • Bare metal
  • Other - added info in Steps to Reproduce

Version Information

Inventree version: 0.16.4
API version: 232

Please verify if you can reproduce this bug on the demo site.

  • I can reproduce this bug on the demo site.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions