* 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>
* full fsm implementation
closes https://github.com/inventree/InvenTree/issues/12314
based on https://github.com/matmair/InvenTree/pull/721
* update assertations
* refactor to reduce duplication
* move for cleaner diff
* more moving stuff around
* fix assingment
* remove skip
* merge test classes
* re-enable transition plugin tests
* fix docstrings
* add depreciation warning
* fix type
* nitpicks
* small cleanup
* ensure we alwas pass a str
* add backport
* fix marker position
* full fsm implementation
closes https://github.com/inventree/InvenTree/issues/12314
based on https://github.com/matmair/InvenTree/pull/721
* update assertations
* refactor to reduce duplication
* move for cleaner diff
* more moving stuff around
* fix assingment
* remove skip
* merge test classes
* re-enable transition plugin tests
* fix docstrings
* add depreciation warning
* fix type
* nitpicks
* small cleanup
* ensure we alwas pass a str
* add backport
* fix marker position
* fix ty issue
* ignore this corner case
* ensure invalid transitions can raise a nice validation error
* compact code
* add depreciation mark
* make raise_error default (#754)
* fix merge
* adjust test as this is now not a no-op but a raised error
* fix assertations
* fix test to not take a broken path
* remove unused test statements
* converge
* add test branch for actually working transition
* reduce uneeded code
* ignore depreceated methods
* fix missing coverage
* add prefetch
* reduce diff
* Add configurable default for PO line item merging
Introduce PURCHASEORDER_MERGE_LINE_ITEMS global setting to control the
default state of the merge_items option when creating purchase order lines.
Fixes#10947
* Apply ruff and biome formatting for CI
* Add "discount" support to order line items
* Fix total_price annotation for ExtraLineItem
* Add regression tests
* Add frontend support
* Updated documentation
* Added docs
* Bump API version and CHANGELOG
* Remove 'total_price' annotation
- Can be achieved using in-memory python methods
* Apply fix for migration testing
* Revert "Apply fix for migration testing"
This reverts commit 8d9f2dce8c.
* Different approach
* Adjust playwright threshold
* Add bulk-delete mixin for order line items
* Add unit tests
* Enable frontend support
* Add CHANGELOG entry
* Add locking control for TransferOrder
* Fix playwright tests
* Fix playwright tests
* Remove MPTT from StockItem model
* cleanup stock fixture file
* Remove tree rebuild code for StockItem
* Adjust API
* Update CHANGELOG and API version
* remove tree references
* Additional checks
* Remove unused tests
* Add data migration test
* fix fk fields
* Cleanup
* Tweak unit test
* Revert bulk-create in unit test
* Don't rebuild StockItem models
* Add bulk_create_and_fetch helper model
- Overcome limitations of mysql
* Add unit test for new bulk-create helper
* Apply new helper to codebase
* Adjust unit test
* bug fix
* Adjust query limits
* Remove assert
* Add <GlobalPreviewDrawer> component
* Allow plugins to interact
* provide either pk or instance data
* open preview drawer from calendar views
* Launch preview drawer directly from tables
* Add preview types
* Fix types
* CLear data on close
* Fix transition
* Allow caller to pass preview component
* AttributeGrid
* Use a table component
* Display info items
* Navigate to detail page from drawer
* Updates
* Refactor to use part detail view
* Display parameters
* Fix image caching
* Apply same to StockItem
* Remove old component
* Refactor details grid component
* Preview panel for PurchaseOrder model
* Implement for SalesOrder
* Support ReturnOrder
* SupplierPart and ManufacturerPart
* Support preview in parameteric tables
* support Company and BuildOrder
* Fix numbervalue
* BuildOrder and SalesOrderShipment
* location and category
* add user setting
* Fix typing
* Handle link clicks within preview drawer
* fixes
* Implement onClose callback
* Handle row click when panel preview is disabled
* Support custom detail links
* update playwright tests
* UI tweaks
* Add CHANGELOG entry
* docs
* define default API params per model type
* Split out more docs pages
* Simplify state ref
* Refactoring
* Simplify PreviewDrawer component
* observe user setting in calendar view
* Enable PreviewDrawer from RowViewAction
* Push render functions onto ModelInformation dict
* Fix lib compilation
* Refactor internal uses of RowViewAction
* typescript fixes
* Simplify PreviewDrawer component structure
* remove TODO placeholders
* Adjust default behavior of "migrate" command
- Does not create new migration files automatically
* Add dummy field - ensure detected by CI
* Revert "Add dummy field - ensure detected by CI"
This reverts commit e7a101fe87.
* Fix typo
* Adjust contributing docs
* Add CHANGELOG entry
* Add "consumable" field to the Part model
* Add frontend integration
* Add badge
* Add docs
* Updated docs
* Add API filtering for new field
* Adjust API filters
* Update backend logic
* Adjust frontend
* Additional unit tests
* Update API version
* update test
* Add consumable icon
---------
Co-authored-by: Matthias Mair <code@mjmair.com>
* Use callback funcs
* Don't use idx to identify rows
* Add debug function for finding why a component re-rendered
* Do not pass 'control' through to each row
* Prevent unnecessary re-rendering of table rows
* Adjust order of operations for hooks
* Keep props hidden
* Use lightweight NumberInput
* Use NumberInput elsewhere
* Add comment
* use rowId instead of idx
* Generic row memos
* Compare errors too
* Fix for BomItemSubstituteRow
* Adjust more forms
* memoize quantity
* Memoize build lines
* Fix re-rendering issues for build allocation
* Fix for useConsumeBuildLinesForm
* Fix for transfer order table
* Fix useReceiveLineItems
* Remove memoized pattern
* Fix row keys
* Cleanup
* Create useStockItems hook for memoizing items
* Refactoring
* More refactoring
* Remove obj reference
- preventing shallow comparison from working
* Add error message to useWhyDidYouUpdate
* Cleanup
* Cleanup dead code
* Adjust modal width
* Change attr name
* Remove autoFillFilters prop
* Adjustments for serialized stock
* Fix typing
* Bump frontend version
* Adjustments for playwright testing
* Fix ref issue
* Remove debug entry
* Update CHANGELOG.md
* Reintroduce index to table header
* Refactor common component
* Add 'active' field to the ProjectCode model
- Allows retiring of old project codes without deleting
* Update UI table
* Refactor ProjectCodeField
* Add unit test
* Bump API version and CHANGELOG
* Optional 'locale' arg to format_money
- Allows override of system locale when generating reports
* Updated documentation
* Add unit tests
* Handle invalid locale
* Handle invalid locale
* Add new global setting to control currency locale in reports
* Use setting in reports
* Add CHANGELOG entry
* Further unit tests
* Add unit tests for new setting
* Update docs
* More docs
* Refactoring:
- Change REPORT_CURRENCY_LOCALE to REPORT_LOCALE
* Extend unit testing
* Refactor format_number
* Add unit tests for explicit format strings
* Update examples for format_date
* Updated unit tests
* Cleanup unit tests
* Fix more tests
* Adjust wording
* Remove global setting - simplify code
* Simplify unit tests
* Revert 'min_digits' to 'leading'
* Fix docs
* Refactor the render_currency function
- Move all functionality into report.py
* Cleanup duplicate code
* Updated docs
* Allow user to specify date_format
* Add support for 'leading' digits in render_currency
* Bug fix
* Fix unit test
* Add tests for "include_symbol"
* Hide expand icon for items without children
* Add searching to CategoryTree API
* Add "level" filter
* Automatically include parent tree when searching
* Include tree_id field
* Add search input to NavigationTree
* Add more API filters
* Load child nodes iteratively
* Fix dynamic loading of nodes
* Highlight selected item
* Include pathstring
* Fix insertion order
* Auto-expand to the selected ID
* Add "no results" message
* Refactor into generic components
* Expand to multi level
* Use async node loading functionality
* Add hovercard
* Implement same functionality for StockLocationTree API endpoint
* Adjust spacing
* Add connecting lines
* Add playwright test
* Bump API version
* Add CHANGELOG entry
* Update docs
* Update screenshot
* [API] Adjust permissions for machine restart
Can only be actioned by a staff user
* Fix import
* Wrong class
* Extend unit test
* Bump API version
* Update CHANGELOG
* Add custom URL fetcher for PDF rendering
* Fix for report helper functions
* Use new fetcher
* Additional unit tests
* Add new setting to control remote URL fetching
* validate URLs against SSRF
* Add global setting to disable URL fetching entirely
* Update docs
* Fix capitalization
* Fix logging backend
* Update CHANGELOG
* Check model permissions for printing
* Add unit tests
* Prevent printing of disabled reports
* Updated unit test
* Adjust unit test for printing
* Update API and CHANGELOG
* Expose properties for column based filtering
* Adjust renderers
* Hide filter if name does not match
* Allow multiple filters on same column
* Better formatting
* Add filtering support for multiple tables
* Revert yarn.lock changes
* Fix date input props
* Updated column
* Add filter to PartTable
* Add playwright tests for new column filters
* Update CHANGELOG
* Updated docs
* Reduce padding
* Update more table filters
* More filter columns
* Adjust playwright test
* Simplify playwright test
* Robustify playwright tests
* Add some delay
* Add some buffer time
* Framework for overriding plugin settings
* Update serializer
* Prevent writing of plugin setting values
* Unit tests
* Update API version and CHANGELOG
* Update docs
* Add Tag API endpoints
* Enable filtering by model type
* Remove old tags filters against Part endpoint
* Add generic tags filter for filtering against tagged items
* Add API unit tests for the tags API endpoints
* Create generic mixin class for adding tags support
* Update existing tagged models
* Add tags to more model types
* Enable new tags API filtering for multiple models
* Add support for tag filtering in part table
* Update transfer table filters
* Add tags filter to more places
* Allow multiple values to be selected as filters
* Add a new 'tags' type form field
* Display tags on part page
* tags support for orders
* Add support for SalesOrderShipment
* build order
* Company support
* SupplierPart and ManufacturerPart
* support StockItem
* Enable tag filtering for attachments
* Make tagslist readonly
* docs
* Mark props as read only
* Update API version
* Update CHANGELOG
* force tags to be case insensitive
* Add playwright test for build order tags
* more playwright testing
* Fix docs link
* Migrations
* Add to serializer
* Set the "creation_date" field to auto_now_add
* Ordering and filtering
* Add unit test
* Add "has_stocktake" filter
* Add test for data migration
* Additional unit tests for StockItem API endpoint
* Udpate API and CHANGELOG
* Add basic auto-allocate functionality
- backend code
- background task
- API endpoint
* Add new endpoint enum
* add frontend components
* Tweak auto-allocate output
* Allow specifying of individual line items
* Tweak error boundary
* Enable bulk-delete of allocated items against sales order
* Refactor stock sorting options
* Allow user to select how to handle serialized stock
* Backport new functionality to BuildOrder allocation
* Refactor sorting options to use enumerated values
* Implement functional unit tests for new feature
* Update API and CHANGELOG
* Additional unit test
* Add playwright testing
* Documentation
* Update docs for build auto-allocate
* Fix dependencies
* Adjust build line filtering
* Fix serializer
* Offload build output functions:
- cancel output
- scrap output
- complete output
Perform these in the background worker, and monitor for progress on the frontend.
* Refactor "build cancel"
- Offload expensive ops to background worker
* Offload build complete task
* Remove @atomic decorator from functions
- Allows operations to be performed "incrementally"
- If one task times out, the next task will get the rest
* Bug fix
* Bump API version
* Fix isInTestMode check
* Handle case where task returns immediately
* Fix docstring
* fix test_api
* Tweak order of operations
* additional unit testing for further coverage
* Adjust unit tests
* Offload order completion tasks
* Remove bad code
* Updated playwright test
* Robustify playwright tests
* Bump number of allowed queries
* Revert "Remove bad code"
This reverts commit 3a3ac3bdc7.
* Revert "Offload order completion tasks"
This reverts commit 6066dabe43.
* realign user API endpoints to make it clearer which one are only applicable to the current user
* fix name
* bump api
* fix test
* fix reference
* fix test exception
* update ref
* reduce breakage
* re-add legacy urls till next `breaking`
* Remove image download support
- Helper function remains (it is used in the supplier plugin mixin)
- No longer available to user
- Close massive security hole entirely
- Will be defunct soon anyway (moving to generic attachments)
* Update CHANGELOG.md
* Bump API version
* Fix for unit tests
* Implementation
* Update API and CHANGELOG
* Annotate response type
* Simplify attachment renaming
- Use the existing API endpoint
* Capture the actual saved path
* Tweak attachment table fields
* Use built-in validation
* Update docs
* Unit testing
* Ignore some lines from coverage
* Check if file exists before deleting
* Add new "raw_amount" field to BomItem model
* Batch process data migration
* Update migration
* Calculate 'quantity' from 'raw_amount' field
* Improve decimal formatting in migration
* Allow raw_amount in serializer
* Adjust frontend form
* API validation and unit tests
* Additional playwright tests
* Update API version and CHANGELOG
* Updated docs
* Fix docstring
* Better handling of empty values
* Tweak unit tests
* Tweak unit test
* Fix unit test
* Adjust form field text
* Adjust migration file
* Tweak playwright tests
* Fix unit test
* Adjust serializers / import-export / playwright
* Fix migration
* Fix validation
* Loosen comparison
---------
Co-authored-by: Matthias Mair <code@mjmair.com>
* Fix "issued_by" for BuildOrder model
- Automatically capture user information
- Mark field as read-only
- Remove from frontend forms
* Add "created_by" property
* Update unit test
* Update API and CHANGELOG
* Further adjustments to unit tests