Repository navigation
Description
Please verify that this bug has NOT been raised before.
- I checked and didn't find a similar issue
Describe the bug*
I created a stock item via the API with initial quantity of 0. I then tried to add stock with the addStock() API call, but get a 400 response:
requests.exceptions.HTTPError: {'detail': 'Error occurred during API request', 'url': 'https://inventree/api/stock/add/', 'method': 'POST', 'status_code': 400, 'body': '{"items":[{"pk":["Stock item is not in stock"]}]}', 'headers': {'AUTHORIZATION': 'Token XXX'}, 'params': {'format': 'json'}, 'data': {'items': [{'pk': 10, 'quantity': 5}]}}
If I manually edit the stock item in the admin interface to set a quantity of (for example) 2, the addStock() API call works as expected.
This doesn't seem specific to the Python API. From the web UI creating a new Stock Item with a quantity of 0 and then trying to Add Stock from the web interface results in a similar error. The UI says: "Form errors exist" and the logs show a code=400 at that time, so it seems the same thing is happening.
Steps to Reproduce
- Create a part
- Create a stock item for the part with quantity 0. Set "delete on depleted" to false.
- Try to add stock to that stock item
Expected behaviour
The add in step #3 above would add the specified quantity to the stock item.
Deployment Method
- Docker
- Package
- Bare metal
- Other - added info in Steps to Reproduce
Version Information
0.17.0
Please verify if you can reproduce this bug on the demo site.
- I can reproduce this bug on the demo site.
Relevant log output
requests.exceptions.HTTPError: {'detail': 'Error occurred during API request', 'url': 'https://inventree/api/stock/add/', 'method': 'POST', 'status_code': 400, 'body': '{"items":[{"pk":["Stock item is not in stock"]}]}', 'headers': {'AUTHORIZATION': 'Token XXX'}, 'params': {'format': 'json'}, 'data': {'items': [{'pk': 10, 'quantity': 5}]}}
Activity
SchrodingersGat commentedon Dec 25, 2024
Hey @nall thanks for reporting this - I've got a fix incoming in #8766