mirror of
https://github.com/inventree/InvenTree.git
synced 2026-01-11 21:57:57 +00:00
* Add ParameterTemplate model - Data structure duplicated from PartParameterTemplate * Apply data migration for templates * Admin integration * API endpoints for ParameterTemplate * Scaffolding * Add validator for ParameterTemplate model type - Update migrations - Make Parameter class abstract (for now) - Validators * API updates - Fix options for model_type - Add API filters * Add definition for Parameter model * Add django admin site integration * Update InvenTreeParameterMixin class - Fetch queryset of all linked Parameter instances - Ensure deletion of linked instances * API endpoints for Parameter instances * Refactor UI table for parameter templates * Add comment for later * Add "enabled" field to ParameterTemplate model * Add new field to serializer * Rough-in new table * Implement generic "parameter" table * Enable parameters for Company model * Change migration for part parameter - Make it "universal" * Remove code for ManufacturerPartParameter * Fix for filters * Add data import for parameter table * Add verbose name to ParameterTemplate model * Removed dead API code * Update global setting * Fix typos * Check global setting for unit validation * Use GenericForeignKey * Add generic relationship to allow reverse lookups * Fixes for table structure * Add custom serializer field for ContentType with choices * Adds ContentTypeField - Handles representation of content type - Provides human-readable options * Refactor API filtering for endpoints - Specify ContentType by ID, model or app label * Revert change to parameters property * Define GenericRelationship for linking model * Refactoring some code * Add a generic way to back-annotate and prefetch parameters for any model type * Change panel position * Directly annotate parameters against different model serializers * remove defunct admin classes * Run plugin validation against parameter * Fix prefetching for PartSerializer * Implement generic "filtering" against queryset * Implement generic "ordering" by parameter * Make parametric table generic * Refactor segmented panels * Consolidate part table views * Fix for parametric part table - Only display parameters for which we know there is a value * Add parametric tables for company views * Fix typo in file name * Prefetch to reduce hits * Add generic API mixin for filtering and ordering by parameter * Fix hook for rebuilding template parameters * Remove serializer * Remove old models * Fix code for copying parameters from category * Implement more parametric tables: - ManufacturerPart - SupplierPart - Fixes and enhancements * Add parameter support for orders * Add UI support for parameters against orders * Update API version * Update CHANGELOG.md * Add parameter support for build orders * Tweak frontend * Add renderer * Remove defunct endpoints * Add migration requirement * Require contenttypes to be updated * Update migration * Try using ID val * Adjust migration dependencies * fix params fixture * fix schema export * fix modelset * Fixes for data migration * tweak table * Fix for Category Parameters * Use branch of demo dataset for testing * Add parameteric build order table * disable broken imports * remove old model from ruleset * correct test * Table tweaks * fix test * Remove old model type * fix test * fix test * Refactor mixin to avoid specifying model type manually * fix test * fix resolve name * remove unneeded import * Tweak unit testing * Fix unit test * Enable bulk-create * More fixes * More unit test tweaks * Enhancements * Unit test fixes * Add some migration tests * Fix admin tests * Fix part tests * adapt expectation * fix remaining typecheck * Docs updates * Rearrange models * fix paramater caching * fix doc links * adjust assumption * Adjust data migration unit tests * docs fixes * Fix docs link * Fixes * Tweak formatting * Add doc for setting * Add metadata view for parameters * Add metadata view for ParamterTemplate * Update CHANGELOG file * Deconflict model_type fields * Invert key:value * Revert "Invert key:value" This reverts commitd555658db2. * fix assert * Update API rev notes * Initial unit tests for API * Test parameter create / edit / delete via the API * Add some more unit tests for the API * Validate queryset annotation - Add unit test with large dataset - Ensure number of queries is fixed - Fix for prefetching check * Add breaking change info to CHANGELOG.md * Ensure that parameters are removed when deleting the linked object * Enhance type hinting * Refactor part parameter exporter plugin - Any model which supports parameters can use this now - Update documentation * Improve serializer field * Adjust unit test * Reimplement checks for locked parts * Fix unit test for data migration * Fix for unit test * Allow disable edit for ParameterTable * Fix supplier part import wizard * Add unit tests for template API filtering * Add playwright tests for purchasing index * Add tests for manufacturing index page * ui tests for sales index * Add data migration tests for ManufacturerPartParameter * Pull specific branch for python binding tests * Specify target migration * Remove debug statement * Tweak migration unit tests * Add options for spectacular * Add explicit choice options * Ensure empty string values are converted to None * Don't use custom branch for python checks * Fix for migration test * Fix migration test * Fix reference target * Remove duplicate enum in spectactular.py * Add null choice to custom serializer class * [UI] Edit shipment details - Pass "pending" status through to the form * New migration strategy: part.0144: - Add new "enabled" field to PartParameterTemplate model - Add new ContentType fields to the "PartParameterTemplate" and "PartParameter" models - Data migration for existing "PartParameter" records part.0145: - Set NOT NULL constraints on new fields - Remove the obsolete "part" field from the "PartParameter" model * More migration updates: - Create new "models" (without moving the existing tables) - Data migration for PartCataegoryParameterTemplate model - Remove PartParameterTemplate and PartParameter models * Overhaul of migration strategy - New models simply point to the old database tables - Perform schema and data migrations on the old models first (in the part app) - Swap model references in correct order * Improve checks for data migrations * Bug fix for data migration * Add migration unit test to ensure that primary keys are maintained * Add playwright test for company parameters * Rename underlying database tables * Fixes for migration unit tests * Revert "Rename underlying database tables" This reverts commit477c692076. * Fix for migration sequencing * Simplify new playwright test * Remove spectacular collision * Monkey patch the drf-spectacular warn function * Do not use custom branch for playwright testing --------- Co-authored-by: Matthias Mair <code@mjmair.com>
155 lines
7.5 KiB
Markdown
155 lines
7.5 KiB
Markdown
---
|
|
title: Parameters
|
|
---
|
|
|
|
## Parameters
|
|
|
|
A *parameter* describes a particular "attribute" or "property" of a specific object in InvenTree. Parameters allow for flexible and customizable data to be stored against various InvenTree models.
|
|
|
|
!!! note "Business Logic"
|
|
Parameters are not used for any core business logic within InvenTree. They are intended to provide additional metadata for objects, which can be useful for documentation, filtering, or reporting purposes.
|
|
|
|
Parameters can be associated with various InvenTree models.
|
|
|
|
### Parameter Tab
|
|
|
|
Any model which supports parameters will have a "Parameters" tab on its detail page. This tab displays all parameters associated with that object:
|
|
|
|
{{ image("concepts/parameter-tab.png", "Part Parameters Example") }}
|
|
|
|
## Parameter Templates
|
|
|
|
Parameter templates are used to define the different types of parameters which are available for use. The following attributes are defined for a parameter template:
|
|
|
|
| Attribute | Description |
|
|
| --- | --- |
|
|
| Name | The name of the parameter template (*must be unique*) |
|
|
| Description | Optional description for the template |
|
|
| Units | Optional units field (*must be a valid [physical unit](#parameter-units)*) |
|
|
| Model Type | The InvenTree model to which this parameter template applies (e.g. Part, Company, etc). If this is left blank, the template can be used for any model type. |
|
|
| Choices | A comma-separated list of valid choices for parameter values linked to this template. |
|
|
| Checkbox | If set, parameters linked to this template can only be assigned values *true* or *false* |
|
|
| Selection List | If set, parameters linked to this template can only be assigned values from the linked [selection list](#selection-lists) |
|
|
|
|
{{ image("concepts/parameter-template.png", "Parameters Template") }}
|
|
|
|
### Create Template
|
|
|
|
Parameter templates are created and edited via the [admin interface](../settings/admin.md).
|
|
|
|
To create a template:
|
|
|
|
- Navigate to the "Settings" page
|
|
- Click on the "Part Parameters" tab
|
|
- Click on the "New Parameter" button
|
|
- Fill out the `Create Part Parameter Template` form: `Name` (required) and `Units` (optional) fields
|
|
- Click on the "Submit" button.
|
|
|
|
An existing template can be edited by clicking on the "Edit" button associated with that template:
|
|
|
|
{{ image("part/parameter_template_edit.png", "Edit Parameter Template") }}
|
|
|
|
### Create Parameter
|
|
|
|
After [creating a template](#create-template) or using the existing templates, you can add parameters to any part.
|
|
|
|
To add a parameter, navigate to a specific part detail page, click on the "Parameters" tab then click on the "New Parameters" button, the `Create Part Parameter` form will be displayed:
|
|
|
|
{{ image("part/create_part_parameter.png", "Create Part Parameter Form") }}
|
|
|
|
Select the parameter `Template` you would like to use for this parameter, fill-out the `Data` field (value of this specific parameter) and click the "Submit" button.
|
|
|
|
## Parametric Tables
|
|
|
|
Parametric tables gather all parameters from all objects of a particular type, to be sorted and filtered.
|
|
|
|
Tables views which support parametric filtering and sorting will have a "Parametric View" button above the table:
|
|
|
|
{{ image("concepts/parametric-parts.png", "Parametric Parts Table") }}
|
|
|
|
### Sorting by Parameter Value
|
|
|
|
The parametric parts table allows the returned parts to be sorted by particular parameter values. Click on the header of a particular parameter column to sort results by that parameter:
|
|
|
|
{{ image("part/part_sort_by_param.png", "Sort by Parameter") }}
|
|
|
|
### Filtering by Parameter Value
|
|
|
|
The parametric parts table allows the returned parts to be filtered by particular parameter values. Click on the {{ icon("filter") }} button associated with the particular parameter, and enter the value you wish to filter against:
|
|
|
|
{{ image("part/filter_by_param.png", "Filter by Parameter") }}
|
|
|
|
The available filter options depend on the type of parameter being filtered. For example, a parameter with a limited set of choices will allow you to filter by those choices, while a numeric parameter will allow you to filter against a specific value and operator (e.g. greater than, less than, etc.).
|
|
|
|
#### Filtering by Multiple Parameters
|
|
|
|
Multiple parameters can be used to filter the parametric table. Simply add a new filter for each parameter you wish to filter against. The results will be filtered to include only parts which match *all* of the specified filters.
|
|
|
|
Each parameter column indicates whether a filter is currently applied:
|
|
|
|
{{ image("part/multiple_param_filters.png", "Multiple Parameter Filters") }}
|
|
|
|
#### Multiple Filters Against the Same Parameter
|
|
|
|
It is possible to apply multiple filters against the same parameter. For example, you can filter for parts with a *Resistance* parameter greater than 10kΩ and less than 100kΩ by adding two filters for the *Resistance* parameter:
|
|
|
|
{{ image("part/multiple_filters_same_param.png", "Multiple Filters on Same Parameter") }}
|
|
|
|
#### Unit-Aware Filtering
|
|
|
|
When filtering against a parameter which has a unit defined, you can specify the value in any compatible unit. The system will automatically convert the value to the base unit defined for that parameter template.
|
|
|
|
For example, to show all parts with a *Resistance* parameter of greater than 10kΩ, you can enter `10k` or `10000` in the filter field, and the system will correctly interpret this as 10,000 ohms.
|
|
|
|
{{ image("part/filter_with_unit.png", "Unit Aware Filters") }}
|
|
|
|
#### Removing Filters
|
|
|
|
To remove a filter against a given parameter, click on the {{ icon("circle-x", color='red') }} button associated with that filter:
|
|
|
|
{{ image("part/remove_param_filter.png", "Remove Parameter Filter") }}
|
|
|
|
#### Available Filter Operators
|
|
|
|
The following filter operators are available for parameter filtering:
|
|
|
|
- `=`: Equal to
|
|
- `>`: Greater than
|
|
- `>=`: Greater than or equal to
|
|
- `<`: Less than
|
|
- `<=`: Less than or equal to
|
|
- `!=`: Not equal to
|
|
- `~`: Contains (for text parameters)
|
|
|
|
## Parameter Units
|
|
|
|
The *units* field (which is defined against a [parameter template](#parameter-templates)) defines the base unit of that template. Any parameters which are created against that unit *must* be specified in compatible units.
|
|
|
|
The in-built conversion functionality means that parameter values can be input in different dimensions - *as long as the dimension is compatible with the base template units*.
|
|
|
|
!!! info "Read Mode"
|
|
Read more about how InvenTree supports [physical units of measure](../concepts/units.md)
|
|
|
|
### Incompatible Units
|
|
|
|
If a part parameter is created with a value which is incompatible with the units specified for the template, it will be rejected:
|
|
|
|
{{ image("part/part_invalid_units.png", "Invalid Parameter Units") }}
|
|
|
|
This behaviour can be disabled if required, so that any parameter value is accepted.
|
|
|
|
### Parameter Unit Sorting
|
|
|
|
Parameter sorting takes unit conversion into account, meaning that values provided in different (but compatible) units are sorted correctly:
|
|
|
|
{{ image("part/part_sorting_units.png", "Sort by Parameter Units") }}
|
|
|
|
### Selection Lists
|
|
|
|
Selection Lists can be used to add a large number of predefined values to a parameter template. This can be useful for parameters which must be selected from a large predefined list of values (e.g. a list of standardized color codes). Choices on templates are limited to 5000 characters, selection lists can be used to overcome this limitation.
|
|
|
|
It is possible that plugins lock selection lists to ensure a known state.
|
|
|
|
|
|
Administration of lists can be done through the Part Parameter section in the [Admin Center](../settings/admin.md#admin-center) or via the API.
|