Skip to content

Cannot add stock once quantity reaches zero #8758

Closed

Description

@nall

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

  1. Create a part
  2. Create a stock item for the part with quantity 0. Set "delete on depleted" to false.
  3. 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

  1. added
    bug
    question
    triage:not-checked
    on Dec 24, 2024
  2. added
    stock
    and removed
    triage:not-checked
    on Dec 25, 2024
  3. added this to the 0.17.1 milestone on Dec 25, 2024
  4. SchrodingersGat commented on Dec 25, 2024

    @SchrodingersGat
    Member

    Hey @nall thanks for reporting this - I've got a fix incoming in #8766

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugquestionstock

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions