Skip to main content

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

  • ๐Ÿ“ฑ Dedicated Page View: Standalone stock removal page accessible via navigation menu for optimal scanning workflow
  • ๐Ÿ“Š Dashboard Widget: Quick access barcode scanner widget on the InvenTree dashboard
  • ๐Ÿ”„ Automatic Quantity Detection: Smart removal quantities based on supplier part package sizes
  • ๐Ÿ“ Scan History: Real-time tracking of recent scans with success/failure status
  • ๐ŸŽฏ Bulk Actions: Custom "Remove Package" action for stock items in the interface
  • ๐Ÿ”Œ RESTful API: Programmatic access for system integration

Prerequisites

  • InvenTree 0.18.0 or later (recommended)
  • Python 3.9 or higher
  • Authenticated user with stock management permissions (Stock.change and Stock.delete)
  • Barcode scanner (optional but recommended for best experience)

Installation

Note: All commands must be run within the InvenTree virtual environment.

Via pip (Recommended)

pip install inventree-continouous-stock-adjustment

Then restart your InvenTree instance.

From Source

git clone https://github.com/DanielDango/inventree-continuous-stock-adjustment.git
cd inventree-continuous-stock-adjustment
pip install -U wheel setuptools
python -m build
pip install dist/inventree_continouous_stock_adjustment-*.whl

Configuration

Enable the Plugin

  1. Go to Settings โ†’ Plugin Settings
  2. Find Continouous Stock Adjustment and toggle Active
  3. No additional settings required

Barcode Setup

The plugin uses InvenTree's built-in barcode system. Ensure parts have barcodes assigned via the part detail page or barcode scanning interface.

Required Permissions

Users need these permissions:

  • Stock.change - Modify stock items
  • Stock.delete - Remove stock

Usage

The plugin provides three ways to remove stock via barcode scanning:

1. Standalone Page View (Recommended)

Access the dedicated stock removal page via the navigation menu or directly at: /app/plugin/continouous-stock-adjustment/stock-removal/

  1. Navigate: Click Stock Removal in the InvenTree navigation menu (or visit the URL directly)
  2. Scan or Enter Barcode: Use a barcode scanner or manually type the barcode
  3. Press Enter or Click Button: The system automatically processes the barcode
  4. View Results: Success/failure notifications appear with quantity and remaining stock details
  5. Check History: Recent scans are displayed below with timestamps

This dedicated page provides the best user experience for continuous barcode scanning operations.

2. Dashboard Widget

Quick access from the InvenTree home dashboard:

  1. Access Dashboard: Navigate to your InvenTree home page
  2. Find Widget: Locate the "Quick Stock Removal" widget
  3. Scan Barcode: Enter or scan a barcode and press Enter
  4. View History: Recent scans appear below the input field

3. Stock Item Actions

Remove packages directly from stock item views:

  1. Navigate to Stock โ†’ Stock Items
  2. Select one or more stock items
  3. Click Actions dropdown โ†’ Remove Package
  4. The plugin removes one package quantity from each selected item

Example Workflow:

1. Scan barcode "ABC123"
2. System 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

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

  1. Barcode Scanning: User scans or enters a barcode
  2. Part Identification: Plugin uses InvenTree's barcode system to identify the part
  3. Quantity Determination:
    • Uses API-specified quantity if provided
    • Otherwise, reads supplier part pack_quantity_native field
    • Defaults to 1 unit if no supplier data exists
  4. Stock Removal: Removes stock from available items (oldest first by ID), handling partial removals across multiple items if needed
  5. Feedback: Returns success/failure with quantity and remaining stock details

Troubleshooting

Issue Solution
Barcode Not Recognized Verify barcode is assigned to a part in InvenTree; check barcode format matches InvenTree's expectations
No Stock Available Ensure stock items exist with quantity > 0 and are not allocated
Permission Denied (403) Verify user authentication and stock management permissions; confirm plugin is active
Removing 1 Instead of Package Qty Check supplier part configuration has pack_quantity_native set; consider specifying quantity in API requests
Page/Widget Not Visible Confirm plugin is active, user is authenticated, and refresh browser cache

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

  1. Build the plugin: python -m build
  2. Install in your InvenTree environment: pip install dist/*.whl
  3. Restart InvenTree
  4. Activate the plugin in settings
  5. 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:

  1. Fork the repository and create a feature branch
  2. Follow code style: Run linters before committing
  3. Test thoroughly: Ensure changes don't break existing functionality
  4. Document changes: Update README if adding new features
  5. 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

Support

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

inventree_continouous_stock_adjustment-0.3.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file inventree_continouous_stock_adjustment-0.3.tar.gz.

File metadata

File hashes

Hashes for inventree_continouous_stock_adjustment-0.3.tar.gz
Algorithm Hash digest
SHA256 4c18798f0d4edd08a54eaa5227f9ede44a3cdc7f230e2df83c1dd3d33ca55f20
MD5 c14465d6d79f658e8ce6ba52e6992371
BLAKE2b-256 27dfabef8a05b7bc14e655e1861888cc384feb4c83925126f1d91bf72aa8317a

See more details on using hashes here.

File details

Details for the file inventree_continouous_stock_adjustment-0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for inventree_continouous_stock_adjustment-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 894db01cdf77a756d2cc1ae12a3d66d598f46c9e8447eb6a8ecadcfd465878c3
MD5 ff57b0a6fbaee219e2ac32e81e722fdd
BLAKE2b-256 daa5d08cd9184706155b61fad1662bec17a999d8f3257b15bca1bb9bda9a5f4f

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