2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 03:30:54 +00:00

Add stale stock email notifications (#9861)

* Add stale stock email notifications

Implement automated email notifications for stock items approaching
their expiry dates. Users receive consolidated daily emails for all
their subscribed parts that are within the configured stale threshold.

Fixes #7866

* Fix for tracing init (#9860)

- Circular include means that settings.DB_ENGINE may not be available

* [bug] Custom state fix (#9858)

* Set status correctly when returning from customer

* Fix for stock item status change

- Reduced set of changes from #9781

* Handle API updates

* Fix variable shadowing

* More intelligent comparison

* Remove debug statement

* fix syntax again (#9863)

* fix(backend): change notification for INVE-W10 (#9864)

implements changes requested in
https://github.com/inventree/InvenTree/pull/9769#issuecomment-3004193476

* Tweak for tracing setup (#9865)

- DB_ENGINE is of the form "django.db.backends.postgresql", not "postgesql"

* Update README.md (#9867)

Update sponsors list

* Remove sleep call (#9866)

* New Crowdin translations by GitHub Action (#9813)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Table default cols (#9868)

* Work in progress

- Seems to reset the columns on page refresh
- Probably related to the useLocalStorage hook

* Do not overwrite until the tablestate is loaded

* Prevent table fetch until data has been loaded from localStorage

* Improved persistance

* Adjust default column visibility

* Adjust playwright test

* Clear data tweak (#9870)

* Tweaks for config path checks

* Update delete-data task

* Tweaks for config path checks (#9869)

* fix instrumentation code (#9872)

* [UI] About tweak (#9874)

* Cleanup server info modal

* Sort package info

* De-sync useLocalStorage (#9873)

* [UI] Fix thumbnail rendering (#9875)

- Fix typo which caused full image to be rendered
- This could cause significant network loading time

* Add stale stock email notifications

Implement automated email notifications for stock items approaching
their expiry dates. Users receive consolidated daily emails for all
their subscribed parts that are within the configured stale threshold.
Revert django.po

Fixes #7866

* fixed pull request issues #9875)

* unit test notifications for stale stock items

---------

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
Co-authored-by: Matthias Mair <code@mjmair.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
gitbock
2025-06-28 00:21:04 +02:00
committed by GitHub
parent 486838b7e7
commit b3feebb53b
4 changed files with 522 additions and 0 deletions

View File

@ -55,6 +55,48 @@ The Part expiry time can be altered using the Part editing form.
{{ image("stock/part_expiry.png", title="Edit part expiry") }}
## Stale Stock Notifications
InvenTree can automatically notify users when stock items are approaching their expiry dates. This feature helps prevent stock from expiring unnoticed by providing advance warning.
### 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".
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
### How It Works
The system runs a daily background task that:
1. **Checks for stale stock**: Identifies stock items with expiry dates within the configured threshold
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
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:
1. Navigate to the part detail page
2. Click the notification bell icon to subscribe
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: