Repository navigation
[Refactor] Stock tracking audit - #13101
Merged
SchrodingersGat merged 26 commits intoOct 27, 2026
Merged
Conversation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…enTree into stock-tracking-audit
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #13101 +/- ##
==========================================
- Coverage 86.87% 86.77% -0.11%
==========================================
Files 1557 1561 +4
Lines 109449 110189 +740
Branches 12091 12080 -11
==========================================
+ Hits 95087 95618 +531
- Misses 14296 14505 +209
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…enTree into stock-tracking-audit
This was referenced Oct 26, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved audit-history loss risks, hidden transaction details, and per-allocation database lookups need correction before approval.
4 open issues
What changed in this PR
Migrates stock tracking into the shared audit log, extending the existing change-history system to cover stock operations and preserve legacy history.
Changes:
- Adds named audit events, transaction notes, reference details, and legacy-data migration.
- Replaces stock-tracking endpoints and UI with permission-filtered audit history.
- Updates stock, order, and build integrations, regression tests, and documentation.
| File | Description |
|---|---|
src/frontend/tests/pages/pui_stock.spec.ts |
Tests stock and part audit-history views. |
src/frontend/src/tables/stock/StockTrackingTable.tsx |
Removes the legacy tracking table. |
src/frontend/src/tables/general/AuditLogTable.tsx |
Displays event labels, details, and notes. |
src/frontend/src/pages/stock/StockDetail.tsx |
Replaces tracking with the History panel. |
src/frontend/src/pages/part/PartStockHistoryDetail.tsx |
Removes the legacy tracking accordion. |
src/frontend/src/pages/Index/Settings/SystemSettings.tsx |
Removes stock-specific retention settings. |
src/frontend/src/forms/StockForms.tsx |
Removes the copy-history option. |
src/frontend/src/components/panels/HistoryPanel.tsx |
Allows history visibility for non-staff users. |
src/frontend/lib/enums/ModelInformation.tsx |
Points stock history to the audit endpoint. |
src/frontend/lib/enums/ApiEndpoints.tsx |
Removes the stock-tracking endpoint constant. |
src/backend/InvenTree/users/ruleset.py |
Removes legacy tracking-model permissions. |
src/backend/InvenTree/stock/tests.py |
Converts stock-history assertions to audit entries. |
src/backend/InvenTree/stock/test_migrations.py |
Tests legacy history conversion. |
src/backend/InvenTree/stock/test_audit.py |
Adds stock-event and permission tests. |
src/backend/InvenTree/stock/test_api.py |
Updates API tests for audit-backed history. |
src/backend/InvenTree/stock/tasks.py |
Removes the legacy retention task. |
src/backend/InvenTree/stock/serializers.py |
Uses audit batching and removes tracking serialization. |
src/backend/InvenTree/stock/migrations/0130_delete_stockitemtracking.py |
Drops the legacy tracking model. |
src/backend/InvenTree/stock/migrations/0129_migrate_stock_tracking_to_audit_log.py |
Converts legacy tracking rows into audit entries. |
src/backend/InvenTree/stock/api.py |
Removes tracking routes and audits serialized creation. |
src/backend/InvenTree/stock/admin.py |
Removes legacy tracking administration. |
src/backend/InvenTree/stock/__init__.py |
Updates the documented model list. |
src/backend/InvenTree/order/test_sales_order.py |
Updates shipment-history assertions. |
src/backend/InvenTree/order/test_audit.py |
Tests stock events generated by orders. |
src/backend/InvenTree/order/test_api.py |
Tests receipt history and serialized statuses. |
src/backend/InvenTree/order/serializers.py |
Adopts audit batching and shared note limits. |
src/backend/InvenTree/order/models.py |
Records receiving, shipping, and return events. |
src/backend/InvenTree/InvenTree/unit_test.py |
Adds stock audit-query helpers. |
src/backend/InvenTree/InvenTree/test_commands.py |
Removes obsolete tracking-model test coverage. |
src/backend/InvenTree/InvenTree/tasks.py |
Updates the batching docstring reference. |
src/backend/InvenTree/InvenTree/serializers.py |
Updates duplication documentation. |
src/backend/InvenTree/InvenTree/models.py |
Adds model-level audit event declarations. |
src/backend/InvenTree/InvenTree/management/commands/bulkloaddata.py |
Updates documentation examples only. |
src/backend/InvenTree/InvenTree/apps.py |
Cleans up obsolete tracking schedules. |
src/backend/InvenTree/InvenTree/api_version.py |
Documents API version 566 and breaking changes. |
src/backend/InvenTree/common/setting/user.py |
Updates history-setting help text. |
src/backend/InvenTree/common/setting/system.py |
Removes legacy stock-retention settings. |
src/backend/InvenTree/build/test_build.py |
Uses audit history for idempotency checks. |
src/backend/InvenTree/build/test_audit.py |
Tests build-generated stock events. |
src/backend/InvenTree/build/test_api.py |
Converts consumption-history assertions. |
src/backend/InvenTree/build/serializers.py |
Uses the stock transaction-note limit. |
src/backend/InvenTree/build/models.py |
Records build stock operations through audit events. |
src/backend/InvenTree/audit/tests.py |
Tests events, batching, permissions, and redaction. |
src/backend/InvenTree/audit/serializers.py |
Exposes event details with reference redaction. |
src/backend/InvenTree/audit/registry.py |
Resolves model-specific event choices and labels. |
src/backend/InvenTree/audit/models.py |
Stores event types, notes, and deltas. |
src/backend/InvenTree/audit/migrations/0003_event_type.py |
Adds event and note database fields. |
src/backend/InvenTree/audit/helpers.py |
Adds event contexts and bulk-creation recording. |
src/backend/InvenTree/audit/context.py |
Tracks pending events and batch correlation IDs. |
src/backend/InvenTree/audit/api.py |
Broadens authenticated access and adds event filtering. |
docs/docs/stock/tracking.md |
Documents audit-backed stock history and retention. |
docs/docs/stock/index.md |
Updates the stock-tracking overview. |
docs/docs/stock/disassemble.md |
Describes disassembly audit events. |
docs/docs/stock/adjust.md |
Documents movement events. |
docs/docs/sales/return_order.md |
Links returns to stock audit history. |
docs/docs/plugins/mixins/validation.md |
Corrects traceability documentation links. |
docs/docs/manufacturing/output.md |
Corrects the serial-generation guide link. |
docs/docs/concepts/audit.md |
Documents events, permissions, and stock coverage. |
CHANGELOG.md |
Announces the breaking tracking migration. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Related PRs
This PR migrates the legacy "stock item tracking" table (which was manually crafted, and only tracked a subset of model changes) to the new audit log table.
Existing (legacy) entries are migrated to the new system.
Breaking Change
This is a breaking change - the existing "stock tracking" API endpoints are removed, and stock tracking entries have been migrated into the global audit log model
Example Screenshot