Bhumin PaladiyaandOliver 501efdcb6e Fix admin search fields and misc code quality issues (#12525)
* 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>
2026-08-20 19:52:08 +10:00
2022-05-20 13:35:07 +02:00
2026-07-29 07:42:53 +10:00
2026-06-20 22:50:32 +10:00
2026-06-20 22:50:32 +10:00
2025-04-26 10:06:46 +10:00
2026-08-20 06:58:03 +10:00
2024-08-25 13:17:24 +10:00
2024-09-08 09:52:00 +10:00
2024-04-16 08:53:03 +10:00

InvenTree logo

InvenTree

Open Source Inventory Management System

License: MITGitHub tag (latest SemVer)Artifact Hub CI Documentation Status Docker Build Netlify Status

OpenSSF Best Practices OpenSSF Scorecard Maintainability Rating

codecov Crowdin GitHub commit activity Docker Pulls

GitHub Org's stars Twitter Follow Subreddit subscribers Mastdon

View Demo · Documentation · Report Bug · Request Feature

🌟 About the Project

InvenTree is an open-source Inventory Management System which provides powerful low-level stock control and part tracking. The core of the InvenTree system is a Python/Django database backend which provides an admin interface (web-based) and a REST API for interaction with external interfaces and applications. A powerful plugin system provides support for custom applications and extensions.

Check out our website for more details.

🧭 Roadmap

Want to see what we are working on? Check out the roadmap tag and horizon milestone.

🛠️ Integration

InvenTree is designed to be extensible, and provides multiple options for integration with external applications or addition of custom plugins:

👾 Tech Stack

Server
Database
Client
DevOps

🧰 Deployment / Getting Started

There are several options to deploy InvenTree.

Single line install - read the docs for supported distros and details about the function:

wget -qO install.sh https://get.inventree.org && bash install.sh

Refer to the getting started guide for a full set of installation and setup instructions.

📱 Mobile App

InvenTree is supported by a companion mobile app which allows users access to stock control information and functionality.

🔒 Code of Conduct & Security Policy

The InvenTree project team is committed to providing a safe and welcoming environment for all users. Please read our Code of Conduct for more information.

InvenTree is following industry best practices for security. Our security policy is included in this repo. We provide dedicated security pages on our documentation site.

👋 Contributing

Contributions are welcomed and encouraged. Please help to make this project even better! Refer to the contribution page.

📜 Translation

Native language translation of the InvenTree web application is community contributed via crowdin. Contributions are welcomed and encouraged.

💸 Sponsor

If you use InvenTree and find it to be useful, please consider sponsoring the project.

💎 Acknowledgements

We want to acknowledge PartKeepr as a valuable predecessor and inspiration. Find a full list of used third-party libraries in the license information dialog of your instance.

❤️ Support

This project is supported by the following sponsors:

Martin Löper Oliver Lippert Seth Smith SpaceQuest Ltd Appwrite Cabot Technologies Markus Kasten Jeff Haynes Daniele Viti Islendur Gibeon-NL Motrac Research Timo Scrappe ATLAS2246 Radek Hladik

With ongoing resources provided by:

Built with Depot Servers by Digital Ocean Deploys by Netlify Translation by Crowdin
CodSpeed Badge Flakiness Badge

⚠️ License

Distributed under the MIT License. See LICENSE.txt for more information.

S
Description
Open Source Inventory Management System
Readme MIT
717 MiB
Languages
Python 68.4%
TypeScript 30.3%
HTML 0.7%
Shell 0.4%