2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-04-16 08:18:53 +00:00

[refactor] Stocktake -> Stock History (#10124)

* Remove STOCKTAKE ruleset

* Adjust wording of settings

* Cleanup

* Improve text for global settings

* Add BulkDeleteMixin to "stocktake" endpoint

* Frontend updates

* Migrations

- Remove field 'last_stocktake' from Part model
- Remove fields 'user' and 'note' from PartStocktake model
- Remove model PartStocktakeReport

* Frontend cleanup

* Rename global setting

* Rewrite stocktake functionality

* Cleanup

* Adds custom exporter for part stocktake data

* Frontend cleanup

* Bump API version

* Tweaks

* Frontend updates

* Fix unit tests

* Fix helper func

* Add docs

* Fix broken link

* Docs updates

* Adjust playwright tests

* Add unit testing for plugin

* Add unit testing for stock history creation

* Fix unit test
This commit is contained in:
Oliver
2025-08-06 08:02:56 +10:00
committed by GitHub
parent b31e16eb98
commit 5574e7cf6b
46 changed files with 599 additions and 1123 deletions

View File

@@ -1,8 +1,10 @@
---
title: Part Stocktake
title: Part Stock History
---
## Part Stocktake
## Part Stock History
InvenTree can track the historical stock levels of parts, allowing users to view past stocktake data and generate reports based on this information.
A *Stocktake* refers to a "snapshot" of stock levels for a particular part, at a specific point in time. Stocktake information is used for tracking a historical record of the quantity and value of part stock.
@@ -25,41 +27,33 @@ The total cost of stock on hand is calculated based on the provided pricing data
!!! info "Cost Range"
Cost data is provided as a *range* of values, accounting for any variability in available pricing data.
### Display Stocktake Data
### Display Historical Stock Data
Historical stocktake data for a particular part can be viewed in the *Stocktake* tab, available on the *Part* page.
Historical stock data for a particular part can be viewed in the *Stock History* tab, available on the *Part* page.
This tab displays a chart of historical stock quantity and cost data, and corresponding tabulated data:
{{ image("part/part_stocktake_tab.png", "Part stocktake tab") }}
If this tab is not visible, ensure that the *Part Stocktake* [user setting](../settings/user.md) is enabled in the *Display Settings* section.
If this tab is not visible, ensure that the *Enable Stock History* [user setting](../settings/user.md) is enabled in the *Display Settings* section.
{{ image("part/part_stocktake_enable_tab.png", "Enable stocktake tab") }}
{{ image("part/part_stocktake_enable_tab.png", "Enable stock history tab") }}
!!! info "Permission Required"
The stocktake tab will be unavailable if your user account does not have the [required permissions](#stocktake-permissions)
## Stocktake Reports
While a *Stocktake* entry records a historical snapshot of stock levels for a single *part*, a *Stocktake Report* is used to generate a report data file which contains stocktake entries for multiple parts. Stocktake reports can be generated for the entire range of parts available in the database, or a subset of parts as determined by user-configurable filters.
Stocktake reports can be [generated manually](#performing-a-stocktake) by the user, or (if enabled) [generated automatically](#automatic-stocktake) at a specified interval.
As there is a lot of data to crunch to build a report, stocktake reports are generated by the [background worker process](../settings/tasks.md). When the report is completed, it is saved to the database and made available for download.
!!! tip "Background Worker"
If the background worker process is not running, stocktake reports will be unavailable!
Stocktake reports are made available for download as a tabulated `.csv` file, which can be opened in many external applications for further analysis.
## Stocktake Settings
## Stock History Settings
There are a number of configuration options available in the [settings view](../settings/global.md):
{{ image("part/part_stocktake_settings.png", "Stocktake settings") }}
| Name | Description | Default | Units |
| ---- | ----------- | ------- | ----- |
{{ globalsetting("STOCKTAKE_ENABLE") }}
{{ globalsetting("STOCKTAKE_EXCLUDE_EXTERNAL") }}
{{ globalsetting("STOCKTAKE_AUTO_DAYS") }}
{{ globalsetting("STOCKTAKE_DELETE_OLD_ENTRIES")}}
{{ globalsetting("STOCKTAKE_DELETE_DAYS") }}
### Enable Stocktake
{{ image("part/part_stocktake_settings.png", "Stock history settings") }}
### Enable Stock History
Enable or disable stocktake functionality. Note that by default, stocktake functionality is disabled.
@@ -67,76 +61,10 @@ Enable or disable stocktake functionality. Note that by default, stocktake funct
Configure the number of days between generation of [automatic stocktake reports](#automatic-stocktake). If this value is set to zero, automatic stocktake reports will not be generated.
### Delete Old Reports
### Delete Old Stock History Entries
Configure how many days stocktake reports will be retained, before being deleted automatically.
If enabled, stock history entries older than the specified number of days will be automatically deleted from the database.
### Historical Stocktake Reports
### Stock History Deletion Interval
The *Stocktake Settings* display also provides a table of historical stocktake reports:
{{ image("part/part_stocktake_report_table.png", "Stocktake report table") }}
## Stocktake Permissions
Stocktake data and actions are protected by the [stocktake role](../settings/permissions.md#role):
| Permission | Actions Available |
| --- | --- |
| `stocktake.view` | View historical stocktake data for parts |
| `stocktake.add` | Perform stocktake and generate reports |
| `stocktake.delete` | Delete stocktake records and reports |
## Performing a Stocktake
Manual stocktake can be performed via the web interface in a number of locations. The user can filter the parts for which the stocktake will be performed. A new stocktake entry will be generated for each selected part, and optionally a report can be generated for download.
When performing a stocktake, various options are presented to the user:
{{ image("part/part_stocktake_generate.png", "Generate stocktake report") }}
| Option | Description |
| --- | --- |
| Part | Limit stocktake context to a part. If the selected part is a [template part](./index.md#template), any variant parts will also be included in the stocktake |
| Category | Limit stocktake context to a single [part category](./index.md#part-category). Parts which exist in child categories (under the selected parent category) will also be included. |
| Location | Limit stocktake context to a single [stock location](../stock/index.md#stock-location). Any parts which have stock items contained in this location (or any child locations) will be included in the stocktake |
| Generate Report | Select this option to generate a [stocktake report](#stocktake-reports) for the selected parts. |
| Update Parts | Select this option to save a new stocktake record for each selected part. |
### Part Stocktake
A stocktake report for a single part can be generated from the *Stocktake Tab* on the part page:
{{ image("part/part_stocktake_from_part.png", "Generate part stocktake report") }}
### Category Stocktake
A stocktake report for a part category can be generated from the *Part Category* page:
{{ image("part/part_stocktake_from_category.png", "Generate category stocktake report") }}
### Location Stocktake
A stocktake report for a stock location can be generated from the *Stock Location* page:
{{ image("part/part_stocktake_from_location.png", "Generate location stocktake report") }}
### Automatic Stocktake
If enabled, stocktake reports can be generated automatically at a configured interval, specified in number of days. Automatic stocktake reports are performed on the entire database of parts.
### API Functionality
Stocktake actions can also be performed via the [API](../api/index.md).
## Stocktake Settings
The following settings are available for stocktake:
| Name | Description | Default | Units |
| ---- | ----------- | ------- | ----- |
{{ globalsetting("STOCKTAKE_ENABLE") }}
{{ globalsetting("STOCKTAKE_EXCLUDE_EXTERNAL") }}
{{ globalsetting("STOCKTAKE_AUTO_DAYS") }}
{{ globalsetting("STOCKTAKE_DELETE_REPORT_DAYS") }}
{{ globalsetting("DISPLAY_PROFILE_INFO") }}
Configure how many days historical stock records are retained in the database.

View File

@@ -107,9 +107,9 @@ This tab is only displayed if the part is marked as *Purchaseable*.
The *Sales Orders* tab shows a list of the sales orders for this part. It provides a view for important sales order information like customer, status, creation and shipment dates.
### Stocktake
### Stock History
The *Stocktake* tab provide historical stock level information, based on user-provided stocktake data. Refer to the [stocktake documentation](./stocktake.md) for further information.
The *Stock History* tab provide historical stock level information. Refer to the [stock history documentation](./stocktake.md) for further information.
### Test Templates