Perform quick and intuitive stock adjustments by scanning barcodes to remove articles from stock
Project description
Continuous Stock Adjustment Plugin for InvenTree
A powerful InvenTree plugin that enables quick and intuitive stock adjustments through barcode scanning. Simply scan a barcode to instantly remove stock items, with automatic package quantity detection from supplier parts.
Features
- ๐ฑ Dashboard Widget: Integrated barcode scanner in the InvenTree dashboard for quick stock removal
- ๐ Automatic Quantity Detection: Automatically determines removal quantity based on supplier part package sizes
- ๐ Real-time Feedback: Instant notifications showing removed quantities and remaining stock
- ๐ Scan History: Keeps track of recent scans with success/failure status
- ๐ฏ Bulk Actions: Custom "Remove Package" action for stock items in the InvenTree interface
- ๐งญ Easy Navigation: Quick access navigation menu item for stock removal
- ๐ RESTful API: Programmatic access via API endpoints for integration with other systems
Prerequisites
- InvenTree: Version 0.18.0 or later (recommended)
- Python: 3.9 or higher
- Barcode Scanner: Hardware or software barcode scanner (optional but recommended)
- Permissions: User must be authenticated and have stock management permissions
Installation
Option 1: Manual Installation via pip
Install the plugin package directly:
# Install the plugin package
pip install inventree-continouous-stock-adjustment
# Restart your InvenTree instance
Option 2: Development Installation
For development or testing:
# Clone the repository
git clone https://github.com/DanielDango/inventree-continuous-stock-adjustment.git
cd inventree-continuous-stock-adjustment
# Install Python dependencies
pip install -U wheel setuptools
# Build the plugin
python -m build
# Install the built package
pip install dist/inventree_continouous_stock_adjustment-*.whl
Note: You must be operating within the InvenTree virtual environment!
Configuration
Enabling the Plugin
- Navigate to Settings โ Plugin Settings in InvenTree
- Find Continouous Stock Adjustment in the plugin list
- Toggle the Active switch to enable the plugin
- The plugin requires no additional settings to function
Barcode Configuration
The plugin works with InvenTree's built-in barcode system:
- Ensure your parts have barcodes assigned in InvenTree
- Barcodes can be assigned to parts through the part detail page or via barcode scanning
- The plugin will automatically detect and use these barcodes during scanning
User Permissions
Users must have the following permissions to use this plugin:
- Authenticated - Must be logged in
- Stock.change - Permission to modify stock items
- Stock.delete - Permission to remove stock
Usage
Dashboard Widget: Quick Stock Removal
The primary way to use this plugin is through the dashboard widget:
- Access the Dashboard: Navigate to your InvenTree home dashboard
- Locate the Widget: Find the "Quick Stock Removal" widget
- Scan or Enter Barcode:
- Use a barcode scanner (recommended for speed)
- Or manually type the barcode and press Enter
- Automatic Processing: The plugin will:
- Identify the part associated with the barcode
- Determine the removal quantity (from supplier part package size, or default to 1)
- Remove stock from available stock items
- Display success message with removed quantity and remaining stock
- View History: Recent scans are displayed below the input with timestamps
Example Workflow:
1. Scan barcode "ABC123"
2. Plugin identifies Part: "Resistor 10kฮฉ"
3. Detects package quantity: 100 pieces from supplier data
4. Removes 100 pieces from stock
5. Shows: "Successfully removed 100 pieces from stock"
6. Displays remaining stock: 500 pieces
Stock Item Actions
Remove packages directly from the stock item view:
- Navigate to Stock โ Stock Items
- Select one or more stock items
- Click the Actions dropdown
- Select Remove Package
- The plugin removes one package quantity (based on supplier part data) from each selected item
API Reference
The plugin exposes a RESTful API endpoint for programmatic access:
Endpoint: Barcode Scan
URL: /plugin/continouous-stock-adjustment/scan/
Method: POST
Authentication: Required (Token or Session)
Request Body
{
"barcode": "ABC123",
"quantity": 10.5 // Optional - if omitted, uses package quantity from supplier part
}
Success Response (200 OK)
{
"success": true,
"message": "Successfully removed 100.0 pieces from stock",
"part_id": 42,
"part_name": "Resistor 10kฮฉ",
"quantity_removed": 100.0,
"remaining_stock": 500.0
}
Error Responses
Barcode Not Found (404)
{
"success": false,
"message": "Barcode not found or does not match a part"
}
Insufficient Stock (400)
{
"success": false,
"message": "No stock available for part: Resistor 10kฮฉ",
"part_id": 42,
"part_name": "Resistor 10kฮฉ"
}
Server Error (500)
{
"success": false,
"message": "Error processing barcode: [error details]"
}
API Usage Example (Python)
import requests
# InvenTree API configuration
INVENTREE_URL = "http://your-inventree-instance.com"
API_TOKEN = "your-api-token"
headers = {
"Authorization": f"Token {API_TOKEN}",
"Content-Type": "application/json"
}
# Scan a barcode and remove stock
response = requests.post(
f"{INVENTREE_URL}/plugin/continouous-stock-adjustment/scan/",
headers=headers,
json={"barcode": "ABC123"}
)
result = response.json()
if result["success"]:
print(f"Removed {result['quantity_removed']} from {result['part_name']}")
print(f"Remaining stock: {result['remaining_stock']}")
else:
print(f"Error: {result['message']}")
API Usage Example (cURL)
curl -X POST http://your-inventree-instance.com/plugin/continouous-stock-adjustment/scan/ \
-H "Authorization: Token your-api-token" \
-H "Content-Type: application/json" \
-d '{"barcode": "ABC123"}'
How It Works
Barcode Scanning Process
- Barcode Input: User scans or enters a barcode
- Barcode Resolution: Plugin uses InvenTree's barcode scanning system to identify the associated part
- Quantity Determination:
- If quantity is specified in the request, uses that value
- Otherwise, attempts to find supplier part with package quantity
- Falls back to removing 1 unit if no supplier data exists
- Stock Removal:
- Finds stock items for the part with available quantity
- Removes stock in order by stock item ID
- Handles partial removals across multiple stock items if needed
- Response: Returns success/failure with detailed information
Package Quantity Detection
The plugin intelligently determines removal quantities:
- Supplier Parts: Checks for
pack_quantity_nativefield - Example: If a supplier sells resistors in packs of 100, scanning once removes 100 pieces
- Fallback: If no supplier data exists, defaults to 1 unit
Stock Item Selection
When removing stock:
- Prioritizes stock items by ID (oldest first)
- Removes from the first item with sufficient quantity
- If insufficient, removes all from first item and continues to next
- Continues until full quantity is removed or stock is exhausted
Troubleshooting
Barcode Not Recognized
Problem: Scanning a barcode shows "Barcode not found"
Solutions:
- Verify the barcode is assigned to a part in InvenTree
- Check that the barcode format matches InvenTree's expected format
- Ensure the barcode scanner is properly configured
- Test by manually entering the barcode value
No Stock Available
Problem: "No stock available for part" error
Solutions:
- Verify stock items exist for the part
- Check that stock items have quantity > 0
- Ensure stock items are not allocated or on hold
- Review stock location and availability
Permission Denied
Problem: API returns 403 Forbidden
Solutions:
- Verify user is authenticated
- Check user has stock management permissions
- Ensure API token is valid and not expired
- Confirm plugin is activated in settings
Package Quantity Not Detected
Problem: Always removes 1 unit instead of package quantity
Solutions:
- Verify supplier parts are configured for the part
- Check that
pack_quantity_nativefield is set in supplier part - Ensure supplier part is linked to the correct part
- Consider specifying quantity explicitly in API requests
Dashboard Widget Not Visible
Problem: Widget doesn't appear on dashboard
Solutions:
- Verify plugin is activated in plugin settings
- Check user is authenticated
- Refresh the page or clear browser cache
- Check browser console for JavaScript errors
Development
Setting Up Development Environment
# Clone the repository
git clone https://github.com/DanielDango/inventree-continuous-stock-adjustment.git
cd inventree-continuous-stock-adjustment
# Install Python dependencies
pip install -U wheel setuptools twine build ruff
# Install pre-commit hooks
pip install pre-commit
pre-commit install
# Install frontend dependencies
cd frontend
npm install
Frontend Development
cd frontend
# Start development server with hot reload
npm run dev
# Extract translations
npm run translate
# Build production bundle
npm run build
# Run linting
npm run lint
# Fix linting issues
npm run lint:fix
Python Development
# Run Python linting
ruff check
# Auto-fix Python issues
ruff check --fix --preview
# Format Python code
ruff format --preview
# Build the plugin package
python -m build
Testing in InvenTree
- Build the plugin:
python -m build - Install in your InvenTree environment:
pip install dist/*.whl - Restart InvenTree
- Activate the plugin in settings
- Test functionality in the dashboard
Project Structure
.
โโโ continouous_stock_adjustment/ # Python plugin code
โ โโโ __init__.py # Version definition
โ โโโ core.py # Main plugin class
โ โโโ views.py # API views
โ โโโ serializers.py # API serializers
โ โโโ api_test.py # API testing script
โโโ frontend/ # React/TypeScript frontend
โ โโโ src/
โ โ โโโ Dashboard.tsx # Dashboard widget component
โ โ โโโ Panel.tsx # Panel component
โ โ โโโ Settings.tsx # Settings component
โ โโโ package.json
โ โโโ vite.config.ts
โโโ pyproject.toml # Python project configuration
โโโ README.md # This file
โโโ LICENSE # MIT License
Contributing
Contributions are welcome! Please follow these guidelines:
- Fork the repository and create a feature branch
- Follow code style: Run linters before committing
- Test thoroughly: Ensure changes don't break existing functionality
- Document changes: Update README if adding new features
- Submit a pull request: With clear description of changes
Code Style
- Python: Follows Ruff linting with preview features
- TypeScript/React: Uses Biome for linting and formatting
- Commits: Use clear, descriptive commit messages
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Daniel Schwab
- Email: daniel.schwab@hadiko.de
- GitHub: @DanielDango
Support
- Issues: Report bugs or request features via GitHub Issues
- Discussions: Ask questions in GitHub Discussions
- InvenTree Docs: Plugin Documentation
Acknowledgments
- Built for the InvenTree inventory management system
- Uses the InvenTree plugin framework and UI components
Note: This plugin requires InvenTree to be properly configured with barcode support and appropriate user permissions for stock management.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inventree_continouous_stock_adjustment-0.2.1.tar.gz.
File metadata
- Download URL: inventree_continouous_stock_adjustment-0.2.1.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e37559f7bf6c89fddca8fab517d4a7485f5c2b11647a5fb844a866b880fd04d
|
|
| MD5 |
7a1cba97c72dca765cba35427a768508
|
|
| BLAKE2b-256 |
afa14fa9b4d1278e6bc6f3ed32a9c156165606ab18b4c33de4d74c3c2c9f8769
|
File details
Details for the file inventree_continouous_stock_adjustment-0.2.1-py3-none-any.whl.
File metadata
- Download URL: inventree_continouous_stock_adjustment-0.2.1-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92dd816f4dd39778762ebaa1d62f4049a83e31343d721c59e8922083993c1ad8
|
|
| MD5 |
471d9a0eb8ba8fce11a952c0a143c7f2
|
|
| BLAKE2b-256 |
55717e820dbd47be449ced3f7e7f005f628c7ad2a107cd6a6681a69c57be0c29
|