### Setup InvenTree Demo Dataset Source: https://docs.inventree.org/en/stable/start/docker_install Installs the InvenTree demo dataset into your instance for quick testing. Use this to get started rapidly. ```bash docker compose run --rm inventree-server invoke dev.setup-test -i ``` -------------------------------- ### Install Frontend Dependencies and Start Development Server Source: https://docs.inventree.org/en/stable/plugins/creator Navigate to the frontend directory, install npm packages, and start the development server for hot reloading. ```bash cd frontend npm install npm run dev ``` -------------------------------- ### Install and Run Development Server Source: https://docs.inventree.org/en/stable/plugins/walkthrough Navigate to the frontend directory and install dependencies, then start the development server to test the plugin in real-time. ```bash npm install npm run dev ``` -------------------------------- ### GET /api/build/item/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/build This is an example of a successful response from the GET /api/build/item/ endpoint. It includes pagination details and a list of build items. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "bom_reference": "string", "build": 0, "build_detail": null, "build_line": 0, "install_into": 0, "install_into_detail": null, "location": 0, "location_detail": null, "part_detail": null, "pk": 0, "quantity": 10.12, "stock_item": 0, "stock_item_detail": null, "supplier_part_detail": null } ] } ``` -------------------------------- ### Start PostgreSQL Service Source: https://docs.inventree.org/en/stable/start/install Starts the PostgreSQL database service. This command should be run after installing PostgreSQL. ```bash sudo service postgresql start ``` -------------------------------- ### GET /api/settings/user/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/settings Example JSON response for the GET /api/settings/user/ endpoint. This shows the structure of user settings data, including count, pagination links, and a list of results. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "api_url": "string", "choices": [ null ], "confirm": true, "confirm_text": "string", "description": "string", "key": "string", "model_name": "string", "name": "string", "pk": 0, "typ": "string", "type": "string", "units": "string", "user": 0, "value": "string" } ] } ``` -------------------------------- ### Run InvenTree Installer Script Source: https://docs.inventree.org/en/stable/start/installer This command downloads and executes the InvenTree installation script. It automates the entire setup process for a production environment. ```bash wget -qO install.sh https://get.inventree.org && bash install.sh ``` -------------------------------- ### GET /api/stock/test/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/stock Example JSON response for the GET /api/stock/test/ endpoint. This example is auto-generated and may not be fully accurate; refer to the schema for precise details. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "attachment": "string", "date": "2022-04-13T15:42:05.901Z", "finished_datetime": "2022-04-13T15:42:05.901Z", "notes": "string", "pk": 0, "result": true, "started_datetime": "2022-04-13T15:42:05.901Z", "stock_item": 0, "template": 0, "template_detail": null, "test_station": "string", "user": 0, "user_detail": null, "value": "string" } ] } ``` -------------------------------- ### Setup Development Tools Source: https://docs.inventree.org/en/stable/develop/contributing Run this command to install and set up development tools, including pre-commit hooks for automated checks before each commit. ```bash invoke dev.setup-dev ``` -------------------------------- ### GET Machine Config Response Example Source: https://docs.inventree.org/en/stable/api/schema/machine Example JSON response for a successful GET request to retrieve a MachineConfig object. This is a generated example and may not be fully accurate. ```json { "active": true, "driver": "string", "initialized": true, "is_driver_available": true, "machine_errors": [ "string" ], "machine_type": "string", "name": "string", "pk": "9eae28c2-bcd6-4651-8ee6-797fd73e70d8", "properties": [ { "group": "string", "key": "string", "max_progress": 0, "type": null, "value": "string" } ], "restart_required": true, "status": 0, "status_model": "string", "status_text": "string" } ``` -------------------------------- ### GET /api/company/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/company This is an example response for the GET /api/company/ endpoint, illustrating the structure of returned company data. Note that this example is auto-generated and may not be fully accurate. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "active": true, "contact": "string", "currency": "string", "description": "string", "email": "derp@meme.org", "image": "string", "is_customer": true, "is_manufacturer": true, "is_supplier": true, "link": "string", "name": "string", "notes": "string", "parameters": [ { "data": "string", "data_numeric": 10.12, "model_id": 49, "model_type": null, "note": "string", "pk": 0, "template": 0, "template_detail": null, "updated": "2022-04-13T15:42:05.901Z", "updated_by": 0, "updated_by_detail": null } ], "parts_manufactured": 0, "parts_supplied": 0, "phone": "string", "pk": 0, "primary_address": null, "remote_image": "string", "tax_id": "string", "website": "string" } ] } ``` -------------------------------- ### Setup Demo Dataset Locally Source: https://docs.inventree.org/en/stable/demo Run this command to install the demo dataset into your local InvenTree instance. Warning: This will delete all existing data. ```bash invoke dev.setup-test -i ``` -------------------------------- ### Starting Plugin Development Server Source: https://docs.inventree.org/en/stable/plugins/frontend Navigate to the frontend directory of your plugin and run 'npm run dev' to start the development server. ```bash cd frontend npm run dev ``` -------------------------------- ### GET /api/settings/global/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/settings This is an example response for the GET /api/settings/global/ endpoint, illustrating the structure of global settings objects. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "api_url": "string", "choices": [ null ], "confirm": true, "confirm_text": "string", "description": "string", "key": "string", "model_name": "string", "name": "string", "pk": 0, "read_only": true, "typ": "string", "type": "string", "units": "string", "value": "string" } ] } ``` -------------------------------- ### Setup Development Environment with Docker Source: https://docs.inventree.org/en/stable/develop/contributing Use these commands to clone the repository, set up a development server with a demo dataset, and run tests using Docker Compose. ```bash git clone https://github.com/inventree/InvenTree.git && cd InvenTree docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run --rm inventree-dev-server invoke install docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run --rm inventree-dev-server invoke dev.setup-test --dev docker compose --project-directory . -f contrib/container/dev-docker-compose.yml up -d ``` -------------------------------- ### GET /api/user/me/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/user This is an example of the JSON response body for the GET /api/user/me/ endpoint, which retrieves details for the current user. Note that this example is auto-generated and may not be fully accurate. ```json { "email": "derp@meme.org", "first_name": "string", "groups": [ { "name": "string", "permissions": {}, "pk": 0, "roles": [ { "can_add": true, "can_change": true, "can_delete": true, "can_view": true, "group": 0, "label": "string", "name": null, "pk": 0 } ], "users": [ { "email": "derp@meme.org", "first_name": "string", "last_name": "string", "pk": 0, "username": "string" } ] } ], "is_active": true, "is_staff": true, "is_superuser": true, "last_name": "string", "pk": 0, "profile": null, "username": "string" } ``` -------------------------------- ### GET /api/units/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/general This is an example JSON response for the GET /api/units/ endpoint, illustrating the structure of custom unit data. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "definition": "string", "name": "string", "pk": 0, "symbol": "string" } ] } ``` -------------------------------- ### GET /api/stock/track/status/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/stock This is an example of a successful response from the GET /api/stock/track/status/ endpoint. It returns the status class and associated values. ```json { "status_class": "string", "values": {} } ``` -------------------------------- ### Setup Development Environment Bare Metal Source: https://docs.inventree.org/en/stable/develop/contributing Commands to set up a local development environment by cloning the repository, creating a virtual environment, and installing dependencies using invoke. ```bash git clone https://github.com/inventree/InvenTree.git && cd InvenTree python3 -m venv env && source env/bin/activate pip install --upgrade --ignore-installed invoke invoke install invoke update invoke dev.setup-dev --tests ``` -------------------------------- ### Example Calculation Walkthrough Source: https://docs.inventree.org/en/stable/manufacturing/bom Demonstrates a step-by-step calculation of the final required production quantity for a component part, incorporating base quantity, attrition, setup quantity, and rounding multiple. ```plaintext Required Quantity = Base Quantity * Number of Assemblies = 3 * 100 = 300 Attrition Value = Required Quantity * Attrition Percentage = 300 * 0.02 = 6 Required Quantity = Required Quantity + Attrition Value = 300 + 6 = 306 Required Quantity = Required Quantity + Setup Quantity = 306 + 10 = 316 Required Quantity = ceil(Required Quantity / Rounding Multiple) * Rounding Multiple = ceil(316 / 25) * 25 = 13 * 25 = 325 ``` -------------------------------- ### GET /api/label/template/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/label Example JSON response for the GET /api/label/template/ endpoint, showing the structure of returned label template data. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "attach_to_model": true, "description": "string", "enabled": true, "filename_pattern": "string", "filters": "string", "height": 10.12, "model_type": "build", "name": "string", "pk": 0, "revision": 0, "template": "string", "updated": "2022-04-13T15:42:05.901Z", "updated_by": 0, "updated_by_detail": null, "width": 10.12 } ] } ``` -------------------------------- ### POST /api/plugins/install/ Source: https://docs.inventree.org/en/stable/api/schema/plugins Installs a plugin from a specified source and version. ```APIDOC ## POST /api/plugins/install/ ### Description Installs a plugin. Requires confirmation and optionally accepts a package name, source URL, and version. ### Method POST ### Endpoint /api/plugins/install/ ### Parameters #### Request Body - **confirm** (boolean) - Required - Confirmation that the user wishes to install the plugin. - **package_name** (string) - Optional - The name of the package to install. - **url** (string) - Optional - Source URL for the package (custom registry or VCS path). - **version** (string) - Optional - Version specifier for the plugin. Leave blank for the latest version. ``` -------------------------------- ### GET /api/stock/track/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/stock This is an example of a successful response from the GET /api/stock/track/ endpoint. It includes pagination details and a list of stock tracking results. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "date": "2022-04-13T15:42:05.901Z", "deltas": null, "item": 0, "item_detail": null, "label": "string", "notes": "string", "part": 0, "part_detail": null, "pk": 0, "tracking_type": 0, "user": 0, "user_detail": null } ] } ``` -------------------------------- ### Define Plugin Entrypoint in setup.py Source: https://docs.inventree.org/en/stable/plugins/develop This snippet demonstrates how to specify the 'inventree_plugins' entry point within a setup.py script, enabling InvenTree to locate and load your plugin. ```python import setuptools # ... setuptools.setup( name='ShopifyIntegrationPlugin' .# .. entry_points={"inventree_plugins": ["ShopifyIntegrationPlugin = path.to.source:ShopifyIntegrationPluginClass"]} ) ``` -------------------------------- ### Install Frontend Packages Source: https://docs.inventree.org/en/stable/develop/react-frontend Run this command to install all required frontend packages within the devcontainer. ```bash invoke int.frontend-install ``` -------------------------------- ### GET /api/part/related/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/part This is an example of the JSON response structure for the GET /api/part/related/ endpoint. It includes pagination details and a list of related part objects. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "note": "string", "part_1": 0, "part_1_detail": null, "part_2": 0, "part_2_detail": null, "pk": 0 } ] } ``` -------------------------------- ### Build Order Example Data Source: https://docs.inventree.org/en/stable/api/schema/build Provides an example of the data structure for a build order, including various fields and their typical values. ```json { "barcode_hash": "string", "batch": "string", "completed": 0, "completion_date": "2022-04-13", "creation_date": "2022-04-13", "destination": 0, "external": true, "issued_by": 0, "issued_by_detail": null, "level": 0, "link": "string", "notes": "string", "overdue": true, "parameters": [ { "data": "string", "data_numeric": 10.12, "model_id": 95, "model_type": null, "note": "string", "pk": 0, "template": 0, "template_detail": null, "updated": "2022-04-13T15:42:05.901Z", "updated_by": 0, "updated_by_detail": null } ], "parent": 0, "part": 0, "part_detail": null, "part_name": "string", "pk": 0, "priority": 43, "project_code": 0, "project_code_detail": null, "project_code_label": "string", "quantity": 100.0, "reference": "string", "responsible": 0, "responsible_detail": null, "sales_order": 0, "start_date": "2022-04-13", "status": 10, "status_custom_key": 10, "status_text": "Pending", "take_from": 0, "target_date": "2022-04-13", "title": "string" } ``` -------------------------------- ### Start Frontend Server Source: https://docs.inventree.org/en/stable/develop/react-frontend Launch the React-based user interface development server in a separate terminal window after the backend server is running. ```bash invoke dev.frontend-server ``` -------------------------------- ### GET /api/part/category/parameters Response Example Source: https://docs.inventree.org/en/stable/api/schema/part This is an example of the JSON response received when calling the GET /api/part/category/parameters endpoint. It includes pagination details and a list of category parameters. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "category": 0, "category_detail": null, "default_value": "string", "pk": 0, "template": 0, "template_detail": null } ] } ``` -------------------------------- ### GET /api/company/part/{id}/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/company This is an example of the JSON response body for a GET request to the /api/company/part/{id}/ endpoint. It details the structure of a SupplierPart object. ```json { "MPN": "string", "SKU": "string", "active": true, "availability_updated": "2022-04-13T15:42:05.901Z", "available": 10.12, "barcode_hash": "string", "description": "string", "in_stock": 10.12, "link": "string", "manufacturer_detail": null, "manufacturer_part": 0, "manufacturer_part_detail": null, "note": "string", "notes": "string", "on_order": 10.12, "pack_quantity": "string", "pack_quantity_native": 10.12, "packaging": "string", "parameters": [ { "data": "string", "data_numeric": 10.12, "model_id": 16, "model_type": null, "note": "string", "pk": 0, "template": 0, "template_detail": null, "updated": "2022-04-13T15:42:05.901Z", "updated_by": 0, "updated_by_detail": null } ], "part": 0, "part_detail": null, "pk": 0, "pretty_name": "string", "price_breaks": [ { "part": 0, "pk": 0, "price": "string", "price_currency": "string", "quantity": 10.12, "supplier": 0, "updated": "2022-04-13T15:42:05.901Z" } ], "primary": true, "supplier": 0, "supplier_detail": null, "tags": [ "string" ], "updated": "2022-04-13T15:42:05.901Z" } ``` -------------------------------- ### Example Javascript Source Path Source: https://docs.inventree.org/en/stable/plugins/mixins/ui Illustrates how to specify a Javascript source file and an optional custom function name for a UI feature. ```json "source": "/static/plugins/my_plugin/my_plugin.js:my_custom_function" ``` -------------------------------- ### GET /api/part/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/part This is an example of a successful JSON response from the GET /api/part/ endpoint. It includes pagination details and a list of part objects, each with various attributes. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "IPN": "string", "active": true, "allocated_to_build_orders": 10.12, "allocated_to_sales_orders": 10.12, "assembly": true, "barcode_hash": "string", "building": 10.12, "category": 0, "category_default_location": 0, "category_detail": null, "category_name": "string", "category_path": [ {} ], "component": true, "copy_category_parameters": true, "creation_date": "2022-04-13", "creation_user": 0, "default_expiry": 88, "default_location": 0, "default_location_detail": null, "description": "string", "duplicate": null, "existing_image": "string", "external_stock": 10.12, "full_name": "string", "image": "string", "in_stock": 10.12, "initial_stock": null, "initial_supplier": null, "is_template": true } ] } ``` -------------------------------- ### Start Backend Server Source: https://docs.inventree.org/en/stable/develop/react-frontend Ensure the backend server is running before launching the frontend server. This command launches the backend API server. ```bash invoke dev.server ``` -------------------------------- ### GET /api/parameter/template/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/general This is an example of the JSON response structure for the GET /api/parameter/template/ endpoint. It includes pagination details and a list of results, each representing a parameter template. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "checkbox": true, "choices": "string", "description": "string", "enabled": true, "model_type": null, "name": "string", "pk": 0, "selectionlist": 0, "units": "string" } ] } ``` -------------------------------- ### GET /api/data-output/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/general This is an example response for the GET /api/data-output/ endpoint. It shows the structure of the returned data, including count, pagination links, and a list of results. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "complete": true, "created": "2022-04-13", "errors": null, "output": "string", "output_type": "string", "pk": 0, "plugin": "string", "progress": 274, "template_name": "string", "total": 165, "user": 0, "user_detail": null } ] } ``` -------------------------------- ### Sample Locate Plugin Implementation Source: https://docs.inventree.org/en/stable/plugins/mixins/locate This sample plugin demonstrates how to implement the LocateMixin by logging location information for both stock items and stock locations. It also shows how to set metadata on the located objects. Use this as a starting point for creating your own custom locate plugins. ```python class SampleLocatePlugin(LocateMixin, InvenTreePlugin): """A very simple example of the 'locate' plugin. This plugin class simply prints location information to the logger. """ NAME = 'SampleLocatePlugin' SLUG = 'samplelocate' TITLE = 'Sample plugin for locating items' VERSION = '0.2' def locate_stock_item(self, item_pk): """Locate a StockItem. Args: item_pk: primary key for item """ from stock.models import StockItem logger.info('SampleLocatePlugin attempting to locate item ID %s', item_pk) try: item = StockItem.objects.get(pk=item_pk) logger.info('StockItem %s located!', item_pk) # Tag metadata item.set_metadata('located', True) except (ValueError, StockItem.DoesNotExist): # pragma: no cover logger.exception('StockItem ID %s does not exist!', item_pk) def locate_stock_location(self, location_pk): """Locate a StockLocation. Args: location_pk: primary key for location """ from stock.models import StockLocation logger.info( 'SampleLocatePlugin attempting to locate location ID %s', location_pk ) try: location = StockLocation.objects.get(pk=location_pk) logger.info("Location exists at '%s'", location.pathstring) # Tag metadata location.set_metadata('located', True) except (ValueError, StockLocation.DoesNotExist): # pragma: no cover logger.exception('Location ID %s does not exist!', location_pk) ``` -------------------------------- ### Sample API Caller Plugin Source: https://docs.inventree.org/en/stable/plugins/mixins/api Demonstrates how to use APICallMixin and SettingsMixin to create a plugin that makes an API call to a specified URL using a token from settings. ```python class SampleApiCallerPlugin(APICallMixin, SettingsMixin, InvenTreePlugin): """A small api call sample.""" NAME = 'Sample API Caller' SETTINGS = { 'API_TOKEN': { 'name': 'API Token', 'protected': True, 'default': 'reqres-free-v1', }, 'API_URL': { 'name': 'External URL', 'description': 'Where is your API located?', 'default': 'api.example.com', }, } API_URL_SETTING = 'API_URL' API_TOKEN_SETTING = 'API_TOKEN' API_TOKEN = 'x-api-key' def get_external_url(self): """Returns data from the sample endpoint.""" return self.api_call('api/users/2') ``` -------------------------------- ### GET /api/admin/email/ Response Example Source: https://docs.inventree.org/en/stable/api/schema/general This is an example of the JSON response structure for the GET /api/admin/email/ endpoint. It includes pagination details and a list of email messages with their associated fields. ```json { "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100", "results": [ { "body": "string", "delivery_options": null, "direction": null, "error_code": "string", "error_message": "string", "error_timestamp": "2022-04-13T15:42:05.901Z", "full_message": "string", "global_id": "d0a497bf-c774-4821-922a-b3fc4de1b4a8", "headers": null, "message_id_key": "string", "pk": "28914a7a-3ad7-4e36-98d2-a74ed0a0e0f5", "priority": null, "sender": "derp@meme.org", "status": null, "subject": "string", "thread": "cae635fc-3bf6-4fe9-b7ac-38c7f9bd60dd", "thread_id_key": "string", "timestamp": "2022-04-13T15:42:05.901Z", "to": "derp@meme.org" } ] } ``` -------------------------------- ### Install Supervisor Source: https://docs.inventree.org/en/stable/start/bare_prod Install the Supervisor process control system using apt-get. This command requires sudo privileges. ```bash sudo apt-get install supervisor ```