-
-
Notifications
You must be signed in to change notification settings - Fork 970
Supplier Mixin #9761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wolflu05
wants to merge
9
commits into
inventree:master
Choose a base branch
from
wolflu05:supplier-mixin
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,867
−57
Open
Supplier Mixin #9761
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2c6fedb
commit initial draft for supplier import
wolflu05 51e4139
complete import wizard
wolflu05 adebfc4
allow importing only mp and sp
wolflu05 e26faf1
improved sample supplier plugin
wolflu05 1d90aa9
add docs
wolflu05 fdc1e24
add tests
wolflu05 fcead76
Merge remote-tracking branch 'upstream/master' into supplier-mixin
wolflu05 d1a03e6
bump api version
wolflu05 8627e4e
fix schema docu
wolflu05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: Supplier Mixin | ||
--- | ||
|
||
## SupplierMixin | ||
|
||
The `SupplierMixin` class enables plugins to integrate with external suppliers, enabling seamless creation of parts, supplier parts, and manufacturer parts with just a few clicks from the supplier. The import process is split into multiple phases: | ||
|
||
- Search supplier | ||
- Select InvenTree category | ||
- Match Part Parameters | ||
- Create initial Stock | ||
|
||
### Import Methods | ||
|
||
When a user initiates a search through the UI, the `get_search_results` function is called, and the search results are returned. These contain a `part_id` which is then passed to `get_import_data` if a user decides to import that specific part. This function should return a bunch of data that is needed for the import process. This data may be cached in the future for the same `part_id`. Then depending if the user only wants to import the supplier and manufacturer part or the whole part, the `import_part`, `import_manufacturer_part` and `import_supplier_part` methods are called automatically. If the user has imported the complete part, the `get_parameters` method is used to get a list of parameters which then can be match to inventree part parameter templates with some provided guidance. Additionally the `get_pricing_data` method is used to extract price breaks which are automatically considered when creating initial stock through the UI in the part import wizard. | ||
|
||
For that to work, a few methods need to be overridden: | ||
|
||
::: plugin.base.supplier.mixins.SupplierMixin | ||
options: | ||
show_bases: False | ||
show_root_heading: False | ||
show_root_toc_entry: False | ||
summary: False | ||
members: | ||
- get_search_results | ||
- get_import_data | ||
- get_pricing_data | ||
- get_parameters | ||
- import_part | ||
- import_manufacturer_part | ||
- import_supplier_part | ||
extra: | ||
show_sources: True | ||
|
||
### Sample Plugin | ||
|
||
A simple example is provided in the InvenTree code base. Note that this uses some static data, but this can be extended in a real world plugin to e.g. call the supplier's API: | ||
|
||
::: plugin.samples.supplier.supplier_sample.SampleSupplierPlugin | ||
options: | ||
show_bases: False | ||
show_root_heading: False | ||
show_root_toc_entry: False | ||
show_source: True | ||
members: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wolflu05 it might be worth looking into a
BulkCreateMixin
class here, to make this a generic approach.I recently added in a
BulkUpdateMixin
- #9313 - which employs a very similar approach. The intent here is to:So, thoughts? A
BulkCreateMixin
would complement theBulkUpdateMixin
andBulkDeleteMixin
classess nicely!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I'll see what I can do and if I need any pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you submit that as a separate PR first? I'd like to be able to review that separately