* feat(frontend): Add filter navigation remove button
* extend docs
* extract and extend labels
* add spacer
* fix test
* small fix
* remove unneeded labels
* add mechanism for not triggering on viewsets
* reduce diff for now
* fix test
---------
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
* fix: trigger pricing recalculation when SupplierPart is saved or deleted
When a SupplierPart's pack_quantity is updated after price breaks have
already been created, the Part's pricing (and BOM cost rollups for any
assemblies using that part) was not recalculated. This is because there
was no post_save or post_delete signal handler for the SupplierPart model
to trigger schedule_pricing_update on the linked Part.
Added post_save and post_delete signal handlers for SupplierPart that
mirror the existing SupplierPriceBreak signal handlers. The pricing
cascade (via update_assemblies) ensures BOM line costs in parent
assemblies are also updated.
Fixes#12285
* style: fix ruff format issues
* style: apply ruff format with --preview flag (matching project config)
* fix: resolve PartPricing.DoesNotExist in pack_quantity test
The test captured self.part.pricing before any PartPricing row existed,
yielding an unsaved instance; the later refresh_from_db() then raised
DoesNotExist. Re-fetch self.part.pricing after the price break creates
the row, matching the pattern in test_supplier_part_pricing.
---------
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
Co-authored-by: Aman Jain <jainamn@amazon.com>
* Fix admin search for StockItemTracking and StockItemTestResult
Add search_fields to StockTrackingAdmin and StockItemTestResultAdmin
- item__part__name: search tracking by part name
- item__serial: search tracking by serial number
- notes: search tracking notes
- stock_item__part__name: search test results by part name
- stock_item__serial: search test results by serial number
- template__test_name: search test results by test template name
- value: search test results by output value
- notes: search test result notes
Also adds a unit test to verify search_fields configuration.
* Fix admin search for PartPricing, PartStocktake, PartRelated, and PartTestTemplate
Add search_fields to PartPricingAdmin, PartStocktakeAdmin, PartRelatedAdmin,
and PartTestTemplateAdmin.
- part__name, part__IPN, part__description: search PartPricing
- part__name, part__IPN: search PartStocktake
- part_1__name, part_2__name: search PartRelated
- part__name, test_name, description: search PartTestTemplate
Also adds unit test assertions to verify search_fields configuration.
* Fix admin search for SalesOrderAllocation and ReturnOrderLineItem
Add search_fields to SalesOrderAllocationAdmin and ReturnOrderLineItemAdmin.
SalesOrderAllocationAdmin:
- line__order__reference: search by Sales Order reference
- line__part__name: search by ordered Part name
- item__part__name: search by allocated Stock Item part name
- item__part__IPN: search by allocated Stock Item IPN
- item__serial: search by Stock Item serial number
ReturnOrderLineItemAdmin:
- order__reference: search by Return Order reference
- order__customer__name: search by Customer name
- item__part__name: search by returned Item part name
- item__serial: search by returned Item serial number
- reference: search by line item reference
Also adds list_display improvements and unit tests to verify
search_fields configuration.
* Fix incorrect identity comparison for status validation
Use '!=' (value comparison) instead of 'is not' (identity comparison)
when comparing custom_status.logical_key with self.instance.status.
Python only caches small integers (-5 to 256). For status codes > 256,
'is not' can return True even when values are equal, causing valid
custom status keys to be incorrectly rejected.
Per PEP 8: always use '==' or '!=' for value comparisons.
* Fix wrong super() method call in DataImportColumnMapAdmin
The formfield_for_dbfield method was incorrectly calling
super().formfield_for_choice_field() instead of super().formfield_for_dbfield().
These are different Django admin methods with different expectations.
formfield_for_choice_field expects choice-type fields, but the 'column'
field is a plain CharField. This could cause incorrect form rendering
or errors when viewing DataImportSession detail in Django Admin.
Fix: call the correct parent method formfield_for_dbfield().
* Fix broken delete() method signature on EmailMessage model
The delete() method used '*kwargs' which collects positional arguments
into a tuple named 'kwargs'. This breaks Django's Model.delete()
contract which expects keyword arguments (using=None, keep_parents=False).
When super().delete(*kwargs) was called, keyword arguments passed by
Django internals would be unpacked incorrectly as positional args.
Fix: use standard '*args, **kwargs' signature and pass both to super().
* Fix bare except clause in order status validation
Replace bare 'except:' with 'except Exception:' in
validate_status_custom_key method.
Bare except catches all BaseException subclasses including SystemExit,
KeyboardInterrupt, and MemoryError which should never be silenced.
The get_logical_value() function performs a database .get() call that
can raise ObjectDoesNotExist or MultipleObjectsReturned, both of which
are subclasses of Exception.
This follows PEP 8 (E722: do not use bare except).
* Fix bare except clauses in machine registry and barcode mixins
Replace bare 'except:' with 'except Exception:' in two locations:
- machine/registry.py: hash computation catches AttributeError or
DoesNotExist when a machine config no longer exists
- plugin/base/barcodes/mixins.py: has_barcode_generation property
catches any error from calling generate(None) on a plugin
Bare except catches all BaseException subclasses including SystemExit
and KeyboardInterrupt which should never be silenced.
This follows PEP 8 (E722: do not use bare except).
* Fix readonly_fields typos and add search_fields in admin classes
* Remove redundant admin field test assertions per review feedback
* Fix file formatting and end-of-file newlines per prek style check
---------
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
* 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>
* [bug] OptionalField race condition
Fixes subtle bug where OptionalField entries can be silenty dropped from an API request due to concurrent requests / race conditions
* Additional unit tests
* Additional guard in metadata.py
* include extra kwargs
* Adjust import/exporting options
* Fix attribute sharing across class instances
* 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
* Fix test result ordering by test timestamps
* Refractor test result comparison helper
* Apply formatting fixes
* Fix frontend formatting
* Avoid mutating test result records
* Add migration for test result ordering
* Retry documentation build
---------
Co-authored-by: jayasree723 <confidentlehmann@tomorjerry.com>
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
* Specify JSON encoder for data import fields
- Fixes encoding issues when importing from XLSX file
* Add regression test
* Fix faulty error handler
* Fix for unit test