Skip to content

Record the quantity actually moved when a transfer exceeds stock - #13295

Merged
SchrodingersGat merged 1 commit into
inventree:masterfrom
Quimxi:fix-transfer-tracking-quantity
Nov 16, 2026
Merged

SchrodingersGat merged 1 commit into
inventree:masterfrom
Quimxi:fix-transfer-tracking-quantity

Conversation

@Quimxi

@Quimxi Quimxi commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #13259

When a transfer requests more than the stock item quantity, StockItem.move() moves the whole item (as before), but the tracking entry stored the requested quantity. This clamps the quantity to the item quantity before the tracking entry and the ITEM_MOVED event are recorded.

  • No change in behaviour: the item is moved exactly as before, and partial moves (quantity < item quantity) are untouched.
  • Added StocktakeTest.test_transfer_more_than_available, covering a move to another location and to the same location. It fails on master (records 25 instead of 10) and passes with the change.

Not included, happy to follow up if wanted:

  • Rejecting an over-quantity transfer in StockAdjustmentItemSerializer instead. I left that out because it would change the API behaviour for clients that rely on "more than available moves everything".
  • Fixing the Move field to 1 for serialized items in the Transfer Stock dialog (frontend).

Tested locally with the stock test suite on SQLite. One unrelated failure (stock.tests.TestResultTest.test_duplicate_item_tests) also fails on master in my environment because plugins were disabled.

Requesting a transfer quantity larger than the stock item quantity moves
the entire item, but the tracking entry recorded the requested quantity.
Clamp the quantity to the item quantity before recording the event.

Fixes inventree#13259

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@netlify

netlify Bot commented Nov 16, 2026

Copy link
Copy Markdown

👷 Deploy request for inventree-web-pui-preview pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit c502478

@SchrodingersGat SchrodingersGat added bug Identifies a bug which needs to be addressed stock Related to Stock models backport Apply this label to a PR to enable auto-backport action backport-to-1.7.x Apply this label to backport a PR to the 1.7.x branch labels Nov 16, 2026
@SchrodingersGat SchrodingersGat added this to the 1.8.0 milestone Nov 16, 2026
@SchrodingersGat

Copy link
Copy Markdown
Member

@Quimxi thanks for the fix :)

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.32%. Comparing base (742c8a5) to head (c502478).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13295      +/-   ##
==========================================
- Coverage   90.34%   90.32%   -0.02%     
==========================================
  Files         901      901              
  Lines       83191    83343     +152     
  Branches     4272     4272              
==========================================
+ Hits        75158    75282     +124     
- Misses       7017     7045      +28     
  Partials     1016     1016              
Flag Coverage Δ
backend 93.88% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 94.33% <100.00%> (-0.05%) ⬇️
Backend General 95.17% <ø> (-0.28%) ⬇️
Frontend 77.44% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SchrodingersGat
SchrodingersGat merged commit dfc5ca9 into inventree:master Nov 16, 2026
59 of 60 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
✅ 1.7.x

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

SchrodingersGat pushed a commit that referenced this pull request Nov 16, 2026
) (#13300)

Requesting a transfer quantity larger than the stock item quantity moves
the entire item, but the tracking entry recorded the requested quantity.
Clamp the quantity to the item quantity before recording the event.

Fixes #13259


(cherry picked from commit dfc5ca9)

Co-authored-by: Quimxi <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Apply this label to a PR to enable auto-backport action backport-to-1.7.x Apply this label to backport a PR to the 1.7.x branch bug Identifies a bug which needs to be addressed stock Related to Stock models

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants