Skip to content

[API] Enhanced filtering for generic parameters - #11383

Merged
SchrodingersGat merged 12 commits into
inventree:masterfrom
SchrodingersGat:params-fix
Feb 19, 2026
Merged

SchrodingersGat merged 12 commits into
inventree:masterfrom
SchrodingersGat:params-fix

Conversation

@SchrodingersGat

@SchrodingersGat SchrodingersGat commented Feb 19, 2026 •

Copy link
Copy Markdown
Member

Ref: #11381

Problem Description

With the introduction of generic parameters the filtering of "part parameters" based on the part category has been broken.

This means that when viewing a given part category, the parametric data table displays columns for every parameter which exists for a part, and is not scope limited to the category. This creates a visually cluttered table with a lot of irrelevant parameters.

e.g. for the "capacitors" category, all parameter templates are displayed including "resistance" "thread" (etc)

image

Solution

The solution is to add some new "generic" filters for the ParameterTemplate API

Filter Description
exists_for_model_id Restrict template results to those which have parameters associated with the given model ID. Extends the functionality of the exists_for_model filter
exists_for_related_model Lookup a related model on the provided base model. e.g. category for part. Needs to be used in conjunction with the exists_for_related_model_id filter
exists_for_related_model_id Specify the instance ID for the related field

So this approach lets us make queries such as:

Return all ParameterTemplate instances for which there are greater than zero Template instances linked with the Part model, for any Part which exists within a provided category

And the API query to achieve the above is structured as:

/api/parameter/template/?active=true&ordering=name&for_model=part&exists_for_model=part&exists_for_related_model=category&exists_for_related_model_id=6

Result

And here we can see that back in the "capacitors" category, only the relevant columns are displayed:

image

Testing

  • Playwright testing for tables
  • API unit testing for new filters

- Allow filtering by model ID as well as model type
- Required for the parameteric data tables
- Enable filtering by base model ID
- Enable filtering by related model ID
@netlify

netlify Bot commented Feb 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit 7e29a08
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/699785015891c90008c0a507

@SchrodingersGat SchrodingersGat added this to the 1.3.0 milestone Feb 19, 2026
@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature api Relates to the API User Interface Related to the frontend / User Interface labels Feb 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the filtering capabilities for generic parameter templates to fix an issue where part parameters displayed columns for all templates regardless of category scope. The solution introduces three new API filters (exists_for_model_id, exists_for_related_model, and exists_for_related_model_id) that enable scoped filtering of parameter templates based on related models like categories.

Changes:

  • Added new API filters to restrict parameter templates to those with parameters associated with specific model instances and their related models
  • Updated frontend components to pass related model information for category-scoped filtering
  • Bumped API version to 455 to reflect new filtering capabilities

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/frontend/src/tables/part/ParametricPartTable.tsx Passes category information to enable category-scoped parameter filtering
src/frontend/src/tables/general/ParametricDataTable.tsx Adds support for related model filtering parameters in API requests
src/backend/InvenTree/common/api.py Implements three new filter methods for scoped parameter template queries
src/backend/InvenTree/InvenTree/api_version.py Increments API version and documents new filter additions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/backend/InvenTree/common/api.py Resolved
Comment thread src/backend/InvenTree/common/api.py Resolved
@codspeed

codspeed Bot commented Feb 19, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 21.96%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚡ 20 improved benchmarks
✅ 24 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ WallTime test_api_list_performance[/api/part/category/] 17.5 ms 16.3 ms +7.58%
⚡ WallTime test_api_options_performance[/api/order/po-line/] 161.8 ms 137.4 ms +17.7%
⚡ WallTime test_api_options_performance[/api/user/roles/] 6.5 ms 6.1 ms +6.14%
⚡ WallTime test_api_list_performance[/api/stock/] 161.3 ms 142.5 ms +13.2%
⚡ WallTime test_api_list_performance[/api/part/] 75.3 ms 70.9 ms +6.2%
⚡ WallTime test_api_list_performance[/api/order/so/] 45.9 ms 41.6 ms +10.15%
⚡ WallTime test_api_list_performance[/api/build/item/] 326.4 ms 271.4 ms +20.27%
⚡ WallTime test_search_performance[stockitem] 108.3 ms 99.3 ms +9.08%
⚡ WallTime test_search_performance[all] 371.1 ms 343.4 ms +8.05%
⚡ WallTime test_api_list_performance[/api/order/so/shipment/] 22.3 ms 21 ms +6.2%
⚡ WallTime test_api_options_performance[/api/build/item/] 336.1 ms 276.5 ms +21.56%
⚡ WallTime test_api_options_performance[/api/part/category/] 14.9 ms 13.8 ms +8%
⚡ WallTime test_search_performance[part] 63.3 ms 58.3 ms +8.48%
⚡ WallTime test_api_options_performance[/api/order/so/] 55.5 ms 51.3 ms +8.05%
⚡ WallTime test_api_options_performance[/api/part/] 65.6 ms 61.2 ms +7.18%
⚡ WallTime test_api_options_performance[/api/stock/location/] 24.8 ms 23.3 ms +6.65%
⚡ WallTime test_api_options_performance[/api/order/so/shipment/] 54.7 ms 48.8 ms +12.29%
⚡ WallTime test_api_options_performance[/api/build/] 57.9 ms 53.1 ms +8.98%
⚡ WallTime test_api_options_performance[/api/build/line/] 408.5 ms 335 ms +21.96%
⚡ WallTime test_api_options_performance[/api/order/po/] 47.6 ms 44.3 ms +7.39%

Comparing SchrodingersGat:params-fix (7e29a08) with master (4e1862a)1

Open in CodSpeed

Footnotes

  1. No successful run was found on master (fc1bfe8) during the generation of this report, so 4e1862a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@codecov

codecov Bot commented Feb 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.37288% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.04%. Comparing base (46e0205) to head (7e29a08).
⚠️ Report is 328 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #11383    +/-   ##
========================================
  Coverage   88.03%   88.04%            
========================================
  Files        1292     1292            
  Lines       58540    58655   +115     
  Branches     1943     1943            
========================================
+ Hits        51538    51644   +106     
- Misses       6518     6527     +9     
  Partials      484      484            
Flag Coverage Δ
backend 89.25% <92.37%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 91.80% <ø> (ø)
Backend General 93.37% <92.30%> (-0.01%) ⬇️
Frontend 70.88% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SchrodingersGat
SchrodingersGat merged commit dd423dc into inventree:master Feb 19, 2026
35 of 36 checks passed
@SchrodingersGat
SchrodingersGat deleted the params-fix branch February 19, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API enhancement This is an suggested enhancement or new feature User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants