Skip to main content

Remove consumed stock from old build orders

Project description

CleanupBuildOrders

An InvenTree plugin that removes consumed stock records from old, completed build orders.

Over time, InvenTree accumulates stock items that were consumed during the build process. These records are useful for traceability while a build is active or recently completed, but become unnecessary clutter after a sufficient period has passed. This plugin automatically identifies and deletes those stale records on a weekly schedule.

How It Works

Each week the plugin queries for stock items that meet all of the following criteria:

  • The item has no serial number
  • The item is not installed in another assembly
  • The item is associated with a completed (non-active) build order
  • The build order's completion date is older than the configured threshold

Deletion is gated behind an explicit confirmation step — the plugin will never delete anything unless the Confirm Deletion setting has been manually enabled. On each scheduled run without confirmation, the plugin sends a notification listing the items that would be deleted, so administrators can review before approving.

Installation

InvenTree Plugin Manager

Search for cleanup-build-orders in the InvenTree plugin manager and install directly from there.

Command Line

pip install cleanup-build-orders

Settings

Build Cleanup Period

Key STOCK_DELETE_PERIOD
Type Integer (months)
Default 24
Minimum 6

How far back to look when identifying old stock records. Any consumed stock item belonging to a build order completed more than this many months ago is eligible for deletion.

Confirm Deletion

Key CONFIRM_DELETE
Type Boolean
Default False

Acts as a one-shot authorisation gate. When set to True, the next scheduled run will proceed with deletion. The setting is automatically reset to False immediately before the deletion loop runs, so each deletion run requires a fresh manual confirmation.

When this setting is False (the default), the scheduled task skips deletion and instead sends a notification summarising the items that are pending removal.

Notification Owner

Key NOTIFY_OWNER
Type Owner (User or Group)
Default (not set)

The user or group to notify when items are pending deletion. Accepts an InvenTree Owner, which can be either a single user or a user group — if a group is chosen, every member receives the notification email listing the eligible stock items, grouped by build order.

If no owner is configured, the notification is sent to all active superuser accounts instead.

Usage

  1. Install the plugin and enable it in InvenTree.
  2. Configure the Build Cleanup Period to match your data retention policy.
  3. Optionally set a Notification Group so the right team members receive the daily digest.
  4. Each week the plugin will log how many items are eligible and send a notification email.
  5. Review the email. When ready to delete, enable Confirm Deletion in the plugin settings.
  6. The next scheduled run (within 7 days) will perform the deletion and reset the confirmation flag.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inventree_build_cleanup-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inventree_build_cleanup-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file inventree_build_cleanup-0.1.0.tar.gz.

File metadata

  • Download URL: inventree_build_cleanup-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for inventree_build_cleanup-0.1.0.tar.gz
Algorithm Hash digest
SHA256 340ee25a7af3ab84b7202bb033810ea11c201ea8d0ca619231a0f264accf5171
MD5 32b6c891e5068f35ab1c64401fed41e4
BLAKE2b-256 0d0911e2f900b45a9fc3af470dd84dc5c691eb3d6ed723843893e87e43187305

See more details on using hashes here.

File details

Details for the file inventree_build_cleanup-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for inventree_build_cleanup-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54aa5748af48ec357d77b55e7983930bbe78dab237d1c27f569d6ad923502475
MD5 8e55c7a790eaf3184b1703b8c04bb790
BLAKE2b-256 6ea8254f39838ad6cb17f14fa1fe6a36ee7d74ebab8a64aaa3b8c0905d2a17ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page