Skip to content

Supplier Mixin - #9761

Merged
SchrodingersGat merged 47 commits into
inventree:masterfrom
wolflu05:supplier-mixin
Oct 17, 2025
Merged

SchrodingersGat merged 47 commits into
inventree:masterfrom
wolflu05:supplier-mixin

Conversation

@wolflu05

@wolflu05 wolflu05 commented Jun 11, 2025 •

Copy link
Copy Markdown
Member

This Adds a supplier mixin so that plugin can provide functions to import data from supplier APIs.

TODO

  • initial import wizard
  • make sure that it works again after closing
  • initial stock creation
  • allow importing only MP and SP
  • check todo comments
  • sample plugin
  • docs
  • tests

Future Ideas

@netlify

netlify Bot commented Jun 11, 2025 •

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 22c7be5
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/68f20e0280a8560008b3c6ff

@wolflu05 wolflu05 added plugin Plugin ecosystem User Interface Related to the frontend / User Interface labels Jun 11, 2025
@wolflu05 wolflu05 added this to the 1.0.0 milestone Jun 11, 2025
@wolflu05 wolflu05 changed the title Suplier Mixin Supplier Mixin Jun 11, 2025
@codecov

codecov Bot commented Jun 11, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.21296% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.68%. Comparing base (24dfbe8) to head (22c7be5).
⚠️ Report is 260 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9761      +/-   ##
==========================================
+ Coverage   87.62%   87.68%   +0.06%     
==========================================
  Files        1266     1272       +6     
  Lines       56923    57337     +414     
  Branches     2047     2043       -4     
==========================================
+ Hits        49877    50277     +400     
- Misses       6543     6557      +14     
  Partials      503      503              
Flag Coverage Δ
backend 89.54% <94.21%> (+0.03%) ⬆️

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

Components Coverage Δ
Backend Apps 91.96% <94.50%> (+0.02%) ⬆️
Backend General 93.71% <ø> (ø)
Frontend 70.10% <ø> (+0.08%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/frontend/src/forms/StockForms.tsx Resolved
@wolflu05

wolflu05 commented Jun 12, 2025 •

Copy link
Copy Markdown
Member Author

And do you have any idea, why the PUI tests fail, I havent touched them in a while and I do net get anything from the error. There seems to be tests failing where I havent changed anything... I would really appriciate some pointers on how to fix them.

Otherwise this PR is ready for a first review.

@wolflu05
wolflu05 marked this pull request as ready for review June 12, 2025 21:53
@matmair

matmair commented Jun 12, 2025

Copy link
Copy Markdown
Member

without looking at it deeply - there is a lot of coverage on the backend missing

@matmair matmair 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.

Very good quality, as always. A few questions / nitpicks; nothing really blocking.
I think a few lines of user docs on this would be good too - if you have time.

This is a great start, there are a few things that I think could be more sketched out (in future PRs, by anyone):

  • Caching
  • Handling of rate limits
  • oAuth (digikey and a few other have that)
  • parameter normalizing among suppliers
  • data structures to handle multiple supplier accounts

Comment thread src/backend/InvenTree/part/api.py Resolved
@wolflu05

Copy link
Copy Markdown
Member Author

Thanks for that feedback, that are some good ideas. I have collected them in the initial PR description now, but I want to make sure that I full understand them:

parameter normalizing among suppliers

What exactly do you mean by that?

data structures to handle multiple supplier accounts

I think that should be the goal of the SettingsMixin and UIMixin, also with the oauth stuff.

And still, I would really appreciate some help with the PUI tests, do you have any idea @SchrodingersGat ?

@wolflu05

Copy link
Copy Markdown
Member Author

@matmair Maybe you can add some clarification on my above questions?

@30350n

30350n commented Jun 24, 2025

Copy link
Copy Markdown
Contributor

parameter normalizing among suppliers

What exactly do you mean by that?

Different supplier parts (even from the same supplier) can feature vastly different formats for the same parameter:

image

This is a whole can of worms and could probably eat up an inifinite amount of time, so I never really looked into this much when developing inventree-part-import. Although I offer the option for users to manually implement things like this as part of their configuration, as I for example did here.

Another thing that relates to this is the Enforce Parameter Units setting. I'm not sure how it works now exactly, but back in the day this would disrupt part creation for any part that failed the "unit check". (This would already include things like the '0.125W, 1/8W' in the above screenshot).

@wolflu05

Copy link
Copy Markdown
Member Author

If I understand that correct, this is already implemented. You may can test that using the static sample plugin.

@matmair

matmair commented Jun 25, 2025

Copy link
Copy Markdown
Member

What exactly do you mean by that?

https://en.wikipedia.org/wiki/Canonical_form#Computing ensuring that parameters and parameter units from different suppliers are handled in a standardized form

If I understand that correct, this is already implemented. You may can test that using the static sample plugin.

I seem to have overlooked that, could you point that out?

data structures to handle multiple supplier accounts

I think that should be the goal of the SettingsMixin and UIMixin, also with the oauth stuff.

That would mean every plugin implements this itself, probably. In the future, I would prefer to have that as a core feature to ensure that the interface is the same between plugins and to make portability between plugins easier, might they become unmaintained / insecure.

@matmair matmair added enhancement This is an suggested enhancement or new feature roadmap This is a roadmap feature with no immediate plans for implementation labels Oct 1, 2025
@wolflu05

wolflu05 commented Oct 2, 2025

Copy link
Copy Markdown
Member Author

I have added it to the changelog now.

@matmair matmair 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.

LGTM; great work

Comment thread CHANGELOG.md Resolved
Co-authored-by: Matthias Mair <[email protected]>
@matmair

matmair commented Oct 6, 2025

Copy link
Copy Markdown
Member

@SchrodingersGat ready for review and merge

@SchrodingersGat

Copy link
Copy Markdown
Member

@wolflu05 I'll get onto this in the next couple of days. Sorry, super swamped!

@SchrodingersGat

Copy link
Copy Markdown
Member

@wolflu05 firstly, great work, this is a huge undertaking and I think a very useful feature.

As this is such a big feature, there are guaranteed to be some issues we will have to track down over the next few release cycles. I hope that you can take charge of these?

@SchrodingersGat

SchrodingersGat commented Oct 17, 2025 •

Copy link
Copy Markdown
Member

Regarding documentation:

While you have documented the plugin mixin type itself, I think it would be good to also add a general documentation page regarding importing parts from a supplier. This should be in the "parts" documentation category, and provide some generic documentation about the requirements and process for importing parts:

  • Install a plugin with the right mixin type
  • Associate plugin with the supplier
  • Where to find the UI elements
  • What the process does

Happy for you to add that now, or we can make it a target for an additional PR?

@SchrodingersGat

Copy link
Copy Markdown
Member

Overall, happy with this, I think that (after maybe some additional docs) we can merge in and make sure it gets tested thoroughly before the next release. Hopefully we can also provide some supplier-specific plugins in the future?

@wolflu05

Copy link
Copy Markdown
Member Author

Thanks for your review. I have added some user docs now. Just let me know if there is something else we need to change.

@SchrodingersGat

Copy link
Copy Markdown
Member

Nice addition, thanks! I apologise in advance for any changes that I will request after this is merged - it's hard to catch everything on such a large feature addition.

@wolflu05

Copy link
Copy Markdown
Member Author

That makes sense. Hope that I will find some time then, because I will be pretty busy for the next weeks.

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

Labels

enhancement This is an suggested enhancement or new feature plugin Plugin ecosystem roadmap This is a roadmap feature with no immediate plans for implementation User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants