Skip to content

Prevent shipping and removing allocated stock - #13298

Merged
SchrodingersGat merged 6 commits into
inventree:masterfrom
mamad2184:fix/allocated-stock-quantity
Nov 24, 2026
Merged

SchrodingersGat merged 6 commits into
inventree:masterfrom
mamad2184:fix/allocated-stock-quantity

Conversation

@mamad2184

Copy link
Copy Markdown
Contributor

Summary

  • Prevents stock removal when it would reduce available stock below active allocations.
  • Ensures shipment completion only counts the quantity of stock actually available.
  • Adds regression tests covering both scenarios.

Testing

  • Verified that removing allocated stock is rejected.
  • Verified that shipment

@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 2700c75

@SchrodingersGat

Copy link
Copy Markdown
Member

@mamad2184 this looks good except for code styling - you should install our prek hooks to auto-format the code for you on commit: https://docs.inventree.org/en/latest/develop/contributing/?h=pre-commit#setup-devtools

@SchrodingersGat SchrodingersGat added bug Identifies a bug which needs to be addressed order Related to purchase orders / sales orders stock Related to Stock models labels Nov 17, 2026
@SchrodingersGat SchrodingersGat added this to the 1.8.0 milestone Nov 17, 2026
@SchrodingersGat SchrodingersGat added 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 17, 2026
@SchrodingersGat

Copy link
Copy Markdown
Member

@mamad2184 I have implemented a shared check for validating against stock allocations on other stock actions endpoints - #13302

Once that is merged, please use the same approach for the "remove stock" API endpoint here

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.78%. Comparing base (78b6dd8) to head (2700c75).
⚠️ Report is 23 commits behind head on master.

❌ Your project status has failed because the head coverage (90.21%) is below the target coverage (92.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13298      +/-   ##
==========================================
- Coverage   90.37%   87.78%   -2.59%     
==========================================
  Files         901      901              
  Lines       83678    87013    +3335     
  Branches     4300     4300              
==========================================
+ Hits        75620    76387     +767     
- Misses       7037     9605    +2568     
  Partials     1021     1021              
Flag Coverage Δ
backend 93.92% <96.66%> (+0.01%) ⬆️

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

Components Coverage Δ
Backend Apps 90.21% <96.66%> (-4.21%) ⬇️
Backend General 95.49% <ø> (ø)
Frontend 77.39% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SchrodingersGat

Copy link
Copy Markdown
Member

@mamad2184 still need you to adjust this based on the comments below :)

@mamad2184

Copy link
Copy Markdown
Contributor Author

ok, please give me some time, ill work on the issue.

@mamad2184

mamad2184 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

please take a look at my latest commit, i think its ready to be merged, thank

@SchrodingersGat
SchrodingersGat enabled auto-merge (squash) November 24, 2026 13:41
@SchrodingersGat
SchrodingersGat merged commit 939df60 into inventree:master Nov 24, 2026
30 of 35 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

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 order Related to purchase orders / sales orders stock Related to Stock models

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants