Support for real-world "physical" units of measure is implemented using the pint Python library. This library provides the following core functions:
- Ensures consistent use of real units for your inventory management
- Convert between compatible units of measure from suppliers
- Enforce use of compatible units when creating part parameters
- Enable custom units as required
InvenTree uses the pint library to convert between compatible units of measure. For example, it is possible to convert between units of mass (e.g. grams, kilograms, pounds, etc) or units of length (e.g. millimeters, inches, etc). This is a powerful feature that ensures that units are used consistently throughout the application.
We support the use of engineering notation for units, which allows for easy conversion between units of different orders of magnitude. For example, the following values would all be considered valid:
Scientific notation is also supported, and can be used to represent very large or very small numbers. For example, the following values would all be considered valid:
Support for scientific notation is case sensitive. For example,
1E3 is a valid value, but
1e3 is not.
The pint library is case sensitive, and units must be specified in the correct case. For example,
kg is a valid unit, but
KG is not. In particular, you need to pay close attention when using SI prefixes (e.g.
k for kilo,
M for mega,
n for nano, etc).
Physical units are supported by the following InvenTree subsystems:
The supplier part model uses real-world units to convert between supplier part quantities and internal stock quantities. Unit conversion rules ensure that only compatible unit types can be supplied
The part parameter template model can specify units of measure, and part parameters can be specified against these templates with compatible units
Out of the box, the Pint library provides a wide range of units for use. However, it may not be sufficient for a given application. In such cases, custom units can be easily defined to meet custom requirements.
Custom units can be defined to provide a new physical quantity, link existing units together, or simply provide an alias for an existing unit.
For further information, refer to the pint documentation regarding custom unit definition
Create Custom Units¶
To view, edit and create custom units, locate the Physical Units tab in the settings panel.