Skip to content

feat(backend): Add generic API helper for transitions - #12693

Draft
matmair wants to merge 23 commits into
inventree:masterfrom
matmair:add-generic-transaction
Draft

feat(backend): Add generic API helper for transitions#12693
matmair wants to merge 23 commits into
inventree:masterfrom
matmair:add-generic-transaction

Conversation

@matmair

@matmair matmair commented Aug 23, 2026

Copy link
Copy Markdown
Member

This PR adds a generic viewset mixin that enables writing much more concise APIs when using FSM transitions - follow up to #12317

@netlify

netlify Bot commented Aug 23, 2026

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 399068d
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a9ef6f5e1a9870008553c1a

@matmair matmair added api Relates to the API refactor labels Aug 23, 2026
@matmair matmair added this to the 1.6.0 milestone Aug 23, 2026
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.00000% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.17%. Comparing base (5a73087) to head (399068d).

❌ Your patch check has failed because the patch coverage (82.52%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12693      +/-   ##
==========================================
- Coverage   87.23%   87.17%   -0.06%     
==========================================
  Files        1487     1488       +1     
  Lines      101393   101496     +103     
  Branches    11547    11524      -23     
==========================================
+ Hits        88448    88481      +33     
- Misses      12882    12953      +71     
+ Partials       63       62       -1     
Flag Coverage Δ
backend 91.17% <84.00%> (-0.04%) ⬇️

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

Components Coverage Δ
Backend Apps 92.45% <83.48%> (-0.05%) ⬇️
Backend General 94.40% <82.52%> (-0.33%) ⬇️
Frontend 79.76% <ø> (-0.12%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matmair

matmair commented Aug 23, 2026

Copy link
Copy Markdown
Member Author

@SchrodingersGat @wolflu05 what do you think about this approach? I use it in some of my plugins, it was partially implemented automatically by Claude due to the high level of duplication in a model with a lot of transitions

@matmair matmair changed the title feat(backend): Add generic api helper for transitions feat(backend): Add generic API helper for transitions Aug 23, 2026
@matmair matmair mentioned this pull request Aug 23, 2026
@matmair
matmair marked this pull request as ready for review August 26, 2026 22:40
@matmair

matmair commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

@SchrodingersGat ready for review

@SchrodingersGat SchrodingersGat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you also apply these helpers to the build model API endpoints?

Comment thread src/backend/InvenTree/order/api.py
@matmair

matmair commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

Can you also apply these helpers to the build model API endpoints?

this new generic approach only applies to DRF viewsets, not GenericViews and the build APIs are not on viewsets yet so that would expand the scope of the PR quite a bit

@matmair
matmair marked this pull request as draft September 7, 2026 20:22
@matmair

matmair commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

i just found a potential information leak in this approach; must review options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants