* feat: add piece_count and piece_size fields to BomItem for cut-to-length parts Manufacturing BOMs frequently require multiple pieces of a specific size cut from continuous stock (cables, tubing, structural profiles). Currently the only way to express "10 pieces of 250mm cable" is to enter the total length (2.5m) as quantity, which loses the piece-count information that purchasing and production need. This adds two optional fields to BomItem: - piece_count: number of discrete pieces required (default: 1) - piece_size: size/length of each piece (e.g. "250 mm") When piece_size is specified, the total quantity is auto-calculated as piece_count × piece_size, maintaining full backward compatibility (existing items effectively have piece_count=1 and empty piece_size). Changes: - Backend: new model fields, migration, updated recalculate_quantity() logic, hash_fields for BOM validation - API: serializer exposes piece_count and piece_size - Frontend: BOM form includes the new fields, BOM table shows them as optional columns Addresses #10274 * refactor: simplify to single piece_count field per reviewer feedback Remove the piece_size field entirely. The existing quantity field already represents the per-piece size/length, so piece_count multiplied by quantity gives the total material requirement. Example: quantity=200mm, piece_count=10 → total 2m of wire in 10 pieces. Changes: - Remove piece_size model field, serializer field, and frontend column/form - Update migration to only add piece_count - Update get_required_quantity() to multiply by piece_count - Restore original recalculate_quantity() without piece_size logic * test/docs: add unit tests and documentation for piece_count field * style: replace ambiguous × with x to fix RUF002 lint error * Address review feedback: api_version bump, changelog, style fix - Bump INVENTREE_API_VERSION to 531 with entry for piece_count field - Add CHANGELOG.md entry under Unreleased > Added - Fix RUF001: replace ambiguous × with x in serializers.py help_text * fix: align piece_count migration help_text with model (RUF001) The 0153 AddField recorded help_text with a Unicode multiplication sign (×), while the model field uses plain 'x' after the RUF001 fix. This mismatch made makemigrations --check flag an unstaged 0154_alter_bomitem_piece_count migration, failing the DB test CI jobs. Update the original migration's help_text (and docstring) to plain 'x' so the field definition matches the model, keeping a single clean migration instead of add-then-alter. * fix: use set_quantity() in piece_count tests BomItem.quantity is a derived field, recalculated from raw_amount on every save() via recalculate_quantity(). Setting item.quantity directly was overwritten back to the fixture value on save, so the tests computed against quantity=3 and failed. Use set_quantity() (which sets raw_amount) to match how quantity is meant to be updated. * ci: re-trigger CI to confirm Firefox E2E failures are transient --------- Co-authored-by: Aman Jain <jainamn@amazon.com>
InvenTree Documentation
This repository hosts the official documentation for InvenTree, an open source inventory management system.
Prerequisites
InvenTree uses MkDocs to convert Markdown format .md files into HTML suitable for viewing in a web browser.
!!! info "Prerequisites" To build and serve this documentation locally (e.g. for development), you will need:
* Python 3 installed on your system.
* An existing InvenTree installation containing the virtual environment that was created during installation.
These instructions assume you followed the [InvenTree bare metal installation instructions](./docs/start/install.md), so you'll have an `inventree` user, a home directory at `/home/inventree`, the InvenTree source code cloned from [GitHub](https://github.com/inventree/inventree) into `/home/inventree/src`, and a virtual environment at `/home/inventree/env`. If you installed InvenTree some other way, this might vary, and you'll have to adjust these instructions accordingly.
!!! warning "Your InvenTree install will be updated!" Some of the commands that follow will make changes to your install, for example, by running any pending database migrations. There's a small risk this may cause issues with your existing installation. If you can't risk this, consider setting up a separate InvenTree installation specifically for documentation development.
Building the documentation locally
To build the documentation locally, run these commands as the inventree user:
$ cd /home/inventree
$ source env/bin/activate
!!! info "(env) prefix"
The shell prompt should now display the (env) prefix, showing that you are operating within the context of the python virtual environment
You can now install the additional packages needed by mkdocs:
$ cd src
$ pip install --require-hashes -r docs/requirements.txt
Schema generation
Building the documentation requires extracting the API schema from the source code.
!!! tip This command is only required when building the documentation for the first time, or when changes have been made to the API schema.
$ invoke build-docs
You will see output similar to this (truncated for brevity):
Running InvenTree database migrations...
Exporting definitions...
Exporting settings definition to '/home/inventree/src/docs/generated/inventree_settings.json'...
Exported InvenTree settings definitions to '/home/inventree/src/docs/generated/inventree_settings.json'
Exported InvenTree tag definitions to '/home/inventree/src/docs/generated/inventree_tags.yml'
Exported InvenTree filter definitions to '/home/inventree/src/docs/generated/inventree_filters.yml'
Exported InvenTree report context definitions to '/home/inventree/src/docs/generated/inventree_report_context.json'
Exporting definitions complete
Exporting schema file to '/home/inventree/src/docs/generated/schema.yml'
Schema export completed: /home/inventree/src/docs/generated/schema.yml
Documentation build complete, but mkdocs not requested
Viewing the documentation
Generate the HTML files from the markdown source files, and start the MkDocs webpage server:
$ mkdocs serve -f docs/mkdocs.yml
You can then point your web browser at http://localhost:8080/
Alternatively, you can use the invoke command:
$ invoke dev.docs-server
If you need to, use the -a option after mkdocs or invoke to set the address and port. Run invoke dev.docs-server --help for details.
Editing the Documentation Files
Once the server is running, it will monitor the documentation files for changes, and regenerate the HTML pages as required. Refresh your web browser to see the changes.
Admonitions
"Admonition" blocks can be added to the documentation source as follows:
!!! info "This is the admonition block title"
This is the admonition block content
Refer to the reference documentation to customize the admonition block to the use-case (eg. warning, missing, info, etc.).
Internal Links
Links to internal documentation pages must use relative pathing, otherwise the link will be broken by the readthedocs URL formatting.
Also, linking to an internal page must use the .md suffix!
For example, to link to the page /part/views from /stock/stocktake, the link must be formed as follows:
Click [here](../part/views.md)
Formatting the link as follows:
Click [here](/part/views)
will result in a broken link.
Images
Images are served from the ./docs/assets/images folder and can be added as follows:
{{ image("image_name.png", base="subfolder", title="Image title") }}
See the image macro in ./docs/main.py for more information.
Icons
Icons can be rendered (using the tabler icon set) as follows:
{{ icon("brand-github", color="red")}}
See the icon macro in ./docs/main.py for more information.
Global variables
Refer to the reference documentation to find out how to add global variables to the documentation site.
Global variables should be added in the # Global Variables section of the mkdocs.yml configuration file.
Credits
This documentation makes use of the mkdocs-material template