master
Replaces the Flask/Alpine web app with a SvelteKit 2 + Svelte 5 rewrite under web/, built on adapter-node and Tailwind v4. Same shape as the reference b4l budget app — no auth, stateless pass-through to InvenTree. New "scan session" flow groups mass scans into a session with live counters (scanned / succeeded / pending / failed). Unknown parts in import mode are fed to a worker pool that spawns inventree-part-import (IMPORT_CONCURRENCY, default 3, with 3-retry). Anything that can't be resolved automatically — parse errors, missing qty, invalid location, API errors, or imports that exhaust retries — drops into a Failures panel with a per-item Fix dialog (edit fields / search existing part / retry import). CSV export on the failure list. Layout is two-column on lg+: scanner + activity on the left, pending imports + failures on the right. Light-theme default. SSE on /api/events streams session and import events to the client. Barcode parser ported from the Python/JS versions and hardened for Digi-Key MH10.8.2 barcodes both with and without GS separators (old parser greedy-matched Q's digits and read "Q6" + "11ZPICK" as 611). Import worker also now treats a subprocess failure followed by a successful findPart as a success, so partial imports (part created but a duplicate parameter trips the DB constraint) no longer land in the Failures panel. Deploy artifacts: systemd unit, nginx example (SSE-friendly), and a step-by-step deploy/README. Requires inventree-part-import >= 1.9.2 on the server for InvenTree 1.x API compatibility. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
InvenTree Stock Tool
A comprehensive barcode scanning application for InvenTree inventory management.
Available in two versions:
- Desktop App (tkinter) - Traditional GUI application
- Web App (Flask) - Modern browser-based interface ⭐ NEW!
Features
- Stock Addition: Add stock to inventory by scanning barcodes
- Stock Updates: Update existing stock levels
- Stock Checking: Check current stock levels
- Part Location: Find where parts are stored
- Async Part Import: Non-blocking background import for unknown parts
- Server Connection Monitoring: Real-time connection status
- Barcode Command Support: Control the app via barcode commands
- Web Interface: Access from any device with a browser (NEW!)
Requirements
- Python 3.9 or higher
- InvenTree server with API access
Installation
Using UV (Recommended)
# Clone the repository
git clone <repository-url>
cd stocktool
# Install with uv
uv sync
# Run the DESKTOP application
uv run stock-tool
# OR run the WEB application
uv run stock-tool-web
# Then open browser to http://localhost:5000
👉 For Web App setup, see WEB_APP.md
Manual Installation
# Install dependencies
pip install sv-ttk pillow requests pyyaml
# Run the application
python src/stocktool/stock_tool_gui_v2.py
Configuration
Create a configuration file at ~/.config/scan_and_import.yaml:
host: https://your-inventree-server.com
token: your-api-token-here
Required Fields
host: Your InvenTree server URL (without trailing slash)token: Your InvenTree API token
Usage
- Select Location: Scan a location barcode or enter location ID
- Select Mode: Choose operation mode (Add Stock, Update Stock, Check Stock, or Locate Part)
- Scan Parts: Scan part barcodes to perform operations
Async Part Import (New!)
When you scan a part that doesn't exist in the system:
- Part is automatically queued for background import
- Continue scanning other parts - no waiting required!
- Watch the "Pending Imports" section to see import progress
- Part is automatically processed when import completes
- Failed imports retry automatically (up to 3 attempts)
Benefits:
- No more UI freezing when importing parts
- Scan multiple unknown parts in quick succession
- Visual feedback showing import progress
- Automatic error handling and retry logic
Barcode Commands
The application supports special barcode commands for quick mode switching:
-
Mode Switching:
MODE:ADD,MODE:IMPORT,ADD_STOCK,IMPORT- Switch to Add Stock modeMODE:UPDATE,UPDATE_STOCK,UPDATE- Switch to Update Stock modeMODE:CHECK,MODE:GET,CHECK_STOCK,CHECK- Switch to Check Stock modeMODE:LOCATE,LOCATE_PART,LOCATE,FIND_PART- Switch to Locate Part mode
-
Debug Control:
DEBUG:ON,DEBUG_ON- Enable debug modeDEBUG:OFF,DEBUG_OFF- Disable debug mode
-
Location Management:
CHANGE_LOCATION,NEW_LOCATION,SET_LOCATION,LOCATION- Change current location
Supported Barcode Formats
The application supports multiple barcode formats:
- JSON-like format:
{PM:PART-CODE,QTY:10} - Separator-based format: Fields separated by
\x1Dor\x1E- Part codes starting with
30Por1P - Quantities starting with
Q
- Part codes starting with
- InvenTree location barcodes:
INV-SL<location_id>
Development
Project Structure
stocktool/
├── src/
│ └── stocktool/
│ ├── __init__.py
│ └── stock_tool_gui_v2.py
├── tests/
│ ├── __init__.py
│ ├── test_add_stock.py
│ ├── test_duplicate_handling.py
│ ├── test_parse_fix.py
│ └── test_stock_level.py
├── pyproject.toml
├── .gitignore
└── README.md
Running Tests
# Using UV
uv run pytest
# Manual
pytest tests/
Building
# Build the package
uv build
# Install locally
uv pip install -e .
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Description
Languages
Python
43.8%
TypeScript
21.7%
Svelte
13%
JavaScript
10.6%
HTML
5.5%
Other
5.3%