Skip to content

Stock transfer accepts a quantity larger than the stock item and records it in the tracking history #13259

Closed

Description

@Quimxi

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

(Searched for: transfer quantity serialized, transfer serial quantity, stock transfer quantity exceeds, move serialized stock quantity, transfer quantity tracking history. The closest are #926 / #927, which disabled the quantity field for serialized stock in the legacy UI.)

Describe the bug*

The Transfer Stock action accepts a quantity greater than the quantity of the stock item. The transfer goes through without a warning, the whole item is moved and its quantity does not change, but the tracking entry records the quantity that was typed, not the quantity that was moved.

With serialized stock this is easy to hit: the Transfer Stock dialog shows an editable "Move" field for a serialized item (quantity 1), so a user can type 4 and the history of that unit then says 4 were moved.

From the code on master (d01645c):

  • StockAdjustmentItemSerializer.validate_quantity (stock/serializers.py) only checks that the quantity is not negative / not zero. It does not compare it with stock_item.quantity, unlike other serializers in the same file that raise "Quantity must not exceed available stock quantity".
  • StockItem.move (stock/models.py) treats any quantity >= self.quantity as a full move, but builds the tracking entry from the requested value: tracking_info = {'quantity': float(quantity)}.

So the stock level stays correct; the history does not. From reading the code this is not specific to serialized items (moving 10 from an item that holds 4 would be recorded as 10), but I only reproduced it with serialized items.

Steps to Reproduce

  1. Take a serialized stock item (quantity 1).
  2. Open it and choose Stock actions > Transfer Stock.
  3. Type 4 in the "Move" field, pick a different location, Submit.
  4. The transfer succeeds without a warning. The item has moved and still has quantity 1. No other stock items were created.
  5. Open the Stock Tracking tab: the new entry shows quantity 4.

Same result through the API:

POST /api/stock/transfer/
{"items": [{"pk": <serialized item>, "quantity": 4}], "location": <other location>, "notes": "test"}

returns success; the tracking entry for the item has deltas: {"location": ..., "quantity": 4.0}. Transferring to the same location with quantity 4 also succeeds and records a "Stock updated" entry with quantity 4.

Expected behaviour

Either of:

  • the API rejects a transfer quantity greater than the item quantity, as other stock serializers already do ("Quantity must not exceed available stock quantity"); or
  • the tracking entry records the quantity actually moved (self.quantity).

In the UI, the Move field for a serialized item could be fixed at 1, as it was in the legacy UI (#926 / #927).

Deployment Method

  • Docker

Version Information

InvenTree 1.5.7, API version 530. Behaviour confirmed by reading the current master code (commit d01645c, 2026-11-05).

From the API root: server InvenTree 1.5.7, apiVersion 530, docker_mode true. The full "About InvenTree" block is not available to a non-staff account.

Try to reproduce on the demo site / Is the bug reproducible on the demo site?

Not tested on the demo site. Reproduced on our own instance (1.5.7) through the UI dialog and the API.

Relevant log output

None: the request succeeds, no error is logged.

I have reviewed this report for correctness and filled out all sections.

  • I have checked this report. I acknowledge that filing bugs via AI agents without review might lead to being blocked.

Activity

  1. SchrodingersGat commented on Nov 13, 2026

    @SchrodingersGat
    Member

    @Quimxi thanks for reporting - looks like it should be a pretty simple fix, would you like to submit a PR to address this?

  2. added
    bug
    stock
    api
    on Nov 13, 2026
  3. added this to the 1.8.0 milestone on Nov 13, 2026
  4. added a commit that references this issue on Nov 16, 2026
    dfc5ca9
  5. added a commit that references this issue on Nov 16, 2026
    de4ce76
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

    apibugstock

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions