Fixes for stale stock (#13369)

* Remove unused settings

Remove settings which have had no effect since the legacy user interface
was removed (or which were never implemented):

- STOCK_SHOW_INSTALLED_ITEMS
- PART_SHOW_RELATED
- BARCODE_INPUT_DELAY
- PLUGIN_UPDATE_CHECK
- REPORT_INLINE (user)
- LABEL_INLINE (user)

Remove them from the settings pages and documentation, and use other
boolean user settings in the tests which used LABEL_INLINE as an example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Respect part creation and duplication settings

The PART_COPY_TESTS, PART_CATEGORY_PARAMETERS and PART_CREATE_SUPPLIER
settings had no effect since the legacy user interface was removed. The
part forms now use them for the defaults of the "copy tests" and "copy
category parameters" options, and to show the initial supplier fields.

Adds Playwright tests for the create and duplicate part forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Enforce expired stock and IPN edit settings

The STOCK_ALLOW_EXPIRED_BUILD, STOCK_ALLOW_EXPIRED_SALE and
PART_ALLOW_EDIT_IPN settings had no effect since the legacy user
interface was removed.

- When stock expiry is enabled, expired stock can only be allocated to
  build orders / sales orders if the corresponding setting permits it.
  This applies to manual (API) allocation, allocation by serial number,
  auto-allocation, and new allocations created via the model. Existing
  allocations of since-expired stock remain editable.
- When PART_ALLOW_EDIT_IPN is disabled, the IPN of an existing part cannot
  be changed via the API, and the IPN field is disabled in the edit form.

Adds unit tests for each allocation path and the IPN rule, a Playwright
test for the IPN field, and documents the expired stock settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Additional docs

* Update CHANGELOG

* Fix playwright test

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
OliverandClaude Opus 5.5 authored and GitHub committed 2026-11-26 11:06:41 +11:00
1 parent ad19adcfea
commit a44d6da500
25 files changed
+647 -101

No files matched your search

-4
View File
@@ -98,7 +98,6 @@ Configuration of barcode functionality:
| Name | Description | Default | Units |
| ---- | ----------- | ------- | ----- |
{{ globalsetting("BARCODE_ENABLE") }}
{{ globalsetting("BARCODE_INPUT_DELAY") }}
{{ globalsetting("BARCODE_WEBCAM_SUPPORT") }}
{{ globalsetting("BARCODE_SHOW_TEXT") }}
{{ globalsetting("BARCODE_GENERATION_PLUGIN") }}
@@ -170,7 +169,6 @@ Configuration of label printing:
{{ globalsetting("PART_ENABLE_REVISION") }}
{{ globalsetting("PART_REVISION_ASSEMBLY_ONLY") }}
{{ globalsetting("PART_NAME_FORMAT") }}
{{ globalsetting("PART_SHOW_RELATED") }}
{{ globalsetting("PART_CREATE_INITIAL") }}
{{ globalsetting("PART_CREATE_SUPPLIER") }}
{{ globalsetting("PART_TEMPLATE") }}
@@ -225,7 +223,6 @@ Configuration of stock item options
{{ globalsetting("STOCK_ALLOW_EXPIRED_BUILD") }}
{{ globalsetting("STOCK_OWNERSHIP_CONTROL") }}
{{ globalsetting("STOCK_LOCATION_DEFAULT_ICON") }}
{{ globalsetting("STOCK_SHOW_INSTALLED_ITEMS") }}
{{ globalsetting("STOCK_ENFORCE_BOM_INSTALLATION") }}
{{ globalsetting("STOCK_ALLOW_OUT_OF_STOCK_TRANSFER") }}
{{ globalsetting("STOCK_MERGE_ON_TRANSFER") }}
@@ -256,7 +253,6 @@ Refer to the [transfer order settings](../stock/transfer_order.md#transfer-order
| Name | Description | Default | Units |
| ---- | ----------- | ------- | ----- |
{{ globalsetting("PLUGIN_ON_STARTUP") }}
{{ globalsetting("PLUGIN_UPDATE_CHECK") }}
{{ globalsetting("ENABLE_PLUGINS_URL") }}
{{ globalsetting("ENABLE_PLUGINS_NAVIGATION") }}
{{ globalsetting("ENABLE_PLUGINS_APP") }}
-2
View File
@@ -80,6 +80,4 @@ Settings for label printing and report generation:
| Name | Description | Default | Units |
| ---- | ----------- | ------- | ----- |
{{ usersetting("REPORT_INLINE") }}
{{ usersetting("LABEL_INLINE") }}
{{ usersetting("LABEL_DEFAULT_PRINTER") }}
+40 -25
View File
@@ -6,43 +6,69 @@ title: Stock Expiry
InvenTree supports stock expiration dates, which allows individual stock items to be automatically marked as *expired* past a certain calendar date.
The stock expiry feature is disabled by default, and must be enabled via the settings menu:
The stock expiry feature is disabled by default, and must be enabled using the {{ globalsetting("STOCK_ENABLE_EXPIRY", short=True) }} setting:
{{ image("stock/enable_stock_expiry.png", title="Enable stock expiry feature") }}
While the stock expiry feature is disabled, expiry dates are hidden from the stock forms and tables, and expired stock is not treated any differently to other stock.
!!! info "Non Expiring Stock"
If a Stock Item is not expected to expire, leave the expiry date field blank, or zero
If a stock item is not expected to expire, leave its expiry date blank.
### Add Expiry Date
When creating a new stock item, the expiry date can be manually set by the user.
When creating a new stock item, the expiry date can be manually set by the user. If the part has a [default expiry time](#part-expiry-time), the expiry date is pre-filled accordingly.
{{ image("stock/expiry_date_create.png", title="Add expiry date") }}
If an expiry date is defined for a particular stock item, it will be displayed on the detail page. If the expiry date has passed (and the stock item is *expired*) then this will also be indicated.
{{ image("stock/item_expired.png", title="Display expiry date") }}
When [receiving items](../purchasing/purchase_order.md) against a purchase order, an expiry date can optionally be specified for each received line item (also pre-filled from the default expiry time of the part).
The expiry date can be adjusted in the stock item edit form.
{{ image("stock/expiry_date_edit.png", title="Edit expiry date") }}
### Expired and Stale Stock
A stock item is:
- **Expired** - if its expiry date has passed
- **Stale** - if its expiry date is approaching, within the number of days specified by the {{ globalsetting("STOCK_STALE_DAYS", short=True) }} setting
The stock item detail page displays an *Expired* or *Stale* badge where applicable, along with the expiry date of the stock item:
{{ image("stock/item_expired.png", title="Display expiry date") }}
### Filter Expired Stock
The various stock display tables can be filtered by *expired* status, and also display a column for the expiry date for each stock item.
Stock item tables display a column for the expiry date of each stock item, and can be filtered by *Expired* and *Stale* status (or by a range of expiry dates).
{{ image("stock/stock_table_expiry.png", title="Filter by stock expiry") }}
### Index Page
### Dashboard
If the stock expiry feature is enabled, expired stock are listed on the InvenTree home page, to provide visibility of expired stock to the users.
The *Expired Stock Items* and *Stale Stock Items* [dashboard](../concepts/ui/index.md#dashboard) widgets show the number of expired (and stale) stock items, providing visibility of expired stock to users.
### Using Expired Stock
If the stock expiry feature is enabled, expired stock cannot be allocated to [build orders](../manufacturing/allocate.md) or [sales orders](../sales/sales_order.md) - whether manually, by serial number, or by auto-allocation. This can be changed with the following settings:
| Setting | Description |
| --- | --- |
| {{ globalsetting("STOCK_ALLOW_EXPIRED_BUILD", short=True) }} | Allow expired stock to be allocated to build orders |
| {{ globalsetting("STOCK_ALLOW_EXPIRED_SALE", short=True) }} | Allow expired stock to be allocated to sales orders |
{{ image("stock/sell_build_expired_stock.png", title="Sell and build expired stock") }}
Existing allocations are not affected if the allocated stock expires (or if these settings are changed).
!!! info "Stock Availability"
Expired stock is still counted as *in stock* - refer to the [stock availability](./availability.md) documentation.
## Part Expiry Time
In addition to allowing manual configuration of expiry dates on a per-item basis, InvenTree also provides the ability to set a "default expiry time" for a particular Part. This expiry time (specified in *days*) is then used to automatically calculate the expiry date when creating a new Stock Item as an instance of the given Part.
For example, if a Part has a default expiry time of 30 days, then any Stock Items created for that Part will automatically have their expiry date set to 30 days in the future.
For example, if a Part has a default expiry time of 30 days, then any Stock Items created for that Part will automatically have their expiry date set to 30 days in the future (unless an expiry date is specified).
!!! info "Non Expiring Parts"
If a part is not expected to expire, set the default expiry time to 0 (zero) days.
@@ -61,11 +87,9 @@ InvenTree can automatically notify users when stock items are approaching their
### Configuration
The stale stock notification system uses the `STOCK_STALE_DAYS` global setting to determine when to send notifications. This setting specifies how many days before expiry (or after expiry) to consider stock items as "stale".
The stale stock notification system uses the {{ globalsetting("STOCK_STALE_DAYS", short=True) }} setting to determine when to send notifications. Any in-stock item with an expiry date earlier than this number of days in the future is included - this includes stock items which have *already* expired.
For example, if `STOCK_STALE_DAYS` is set to 10:
- Stock items expiring within the next 10 days will trigger notifications
- Stock items that expired within the last 10 days will also trigger notifications
For example, if {{ globalsetting("STOCK_STALE_DAYS", short=True) }} is set to 10, stock items which expire within the next 10 days (and any stock items which have already expired) will be included in the notifications.
### How It Works
@@ -75,18 +99,15 @@ The system runs a daily background task that:
2. **Groups by user**: Organizes stale items by users who are subscribed to notifications for the relevant parts
3. **Sends consolidated emails**: Each user receives a single email containing all their stale stock items
### Prerequisites
For stale stock notifications to work:
1. **Stock expiry must be enabled**: The `STOCK_ENABLE_EXPIRY` setting must be enabled
2. **Stale days configured**: The `STOCK_STALE_DAYS` setting must be greater than 0
1. **Stock expiry must be enabled**: The {{ globalsetting("STOCK_ENABLE_EXPIRY", short=True) }} setting must be enabled
2. **Stale days configured**: The {{ globalsetting("STOCK_STALE_DAYS", short=True) }} setting must be greater than 0
3. **Email configuration**: [Email settings](../settings/email.md) must be properly configured
4. **User subscriptions**: Users must be subscribed to notifications for the relevant parts
### User Subscriptions
Users will only receive notifications for parts they are subscribed to. To subscribe to part notifications:
@@ -96,9 +117,3 @@ Users will only receive notifications for parts they are subscribed to. To subsc
3. Users can also subscribe to entire part categories
For more information on part subscriptions, see the [Part Notifications](../part/notification.md) documentation.
## Sales and Build Orders
By default, expired Stock Items cannot be added to neither a Sales Order nor a Build Order. This behavior can be adjusted using the *Sell Expired Stock* and *Build Expired Stock* settings:
{{ image("stock/sell_build_expired_stock.png", title="Sell and build expired stock") }}
+1 -1
View File
@@ -72,7 +72,7 @@ There are two ways that a stock item can become installed inside another:
Any stock items installed within a particular stock item are displayed on the *Installed Items* tab of the *Stock Item Detail* page.
By default, installed stock items are hidden from general stock item tables (as they are not directly available for use) - this can be changed using the {{ globalsetting("STOCK_SHOW_INSTALLED_ITEMS", short=True) }} setting.
Installed stock items are not *in stock*, so they are hidden from stock item tables which only display in-stock items (the default). To display installed items in a stock table, remove the *In Stock* filter, or use the *Installed* filter.
### Removing Installed Items