mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-18 23:17:41 +00:00
Supplier Mixin (#9761)
* commit initial draft for supplier import * complete import wizard * allow importing only mp and sp * improved sample supplier plugin * add docs * add tests * bump api version * fix schema docu * fix issues from code review * commit unstaged changes * fix test * refactor part parameter bulk creation * try to fix test * fix tests * fix test for mysql * fix test * support multiple suppliers by a single plugin * hide import button if there is no supplier import plugin * make form submitable via enter * add pui test * try to prevent race condition * refactor api calls in pui tests * try to fix tests again? * fix tests * trigger: ci * update changelog * fix api_version * fix style * Update CHANGELOG.md Co-authored-by: Matthias Mair <code@mjmair.com> * add user docs --------- Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
BIN
docs/docs/assets/images/part/import_part.png
Normal file
BIN
docs/docs/assets/images/part/import_part.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 482 KiB |
BIN
docs/docs/assets/images/part/import_part_wizard.png
Normal file
BIN
docs/docs/assets/images/part/import_part_wizard.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 684 KiB |
BIN
docs/docs/assets/images/part/import_supplier_part.png
Normal file
BIN
docs/docs/assets/images/part/import_supplier_part.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 519 KiB |
28
docs/docs/part/import.md
Normal file
28
docs/docs/part/import.md
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: Importing Data from suppliers
|
||||
---
|
||||
|
||||
## Import data from suppliers
|
||||
|
||||
InvenTree can integrate with external suppliers and import data from them, which helps to setup your system. Currently parts, supplier parts and manufacturer parts can be created automatically.
|
||||
|
||||
### Requirements
|
||||
|
||||
1. Install a supplier mixin plugin for you supplier
|
||||
2. Goto "Admin Center > Plugins > [The supplier plugin]" and set the supplier company setting. Some plugins may require additional settings like API tokens.
|
||||
|
||||
### Import a part
|
||||
|
||||
New parts can be imported from the _Part Category_ view, by pressing the _Import Part_ button:
|
||||
|
||||
{{ image("part/import_part.png", "Import part") }}
|
||||
|
||||
Then just follow the wizard to confirm the category, select the parameters and create initial stock.
|
||||
|
||||
{{ image("part/import_part_wizard.png", "Import part wizard") }}
|
||||
|
||||
### Import a supplier part
|
||||
|
||||
If you already have the part created, you can also just import the supplier part with it's corresponding manufacturer part. Open the supplier panel for the part and use the "Import supplier part" button:
|
||||
|
||||
{{ image("part/import_supplier_part.png", "Import supplier part") }}
|
48
docs/docs/plugins/mixins/supplier.md
Normal file
48
docs/docs/plugins/mixins/supplier.md
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
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
|
||||
|
||||
A plugin can connect to multiple suppliers. The `get_suppliers` method should return a list of available supplier connections (e.g. using different credentials).
|
||||
When a user initiates a search through the UI, the `get_search_results` function is called with the search term, supplier slug returned previously, and the search results are returned. These contain a `part_id` which is then passed to `get_import_data` along with the `supplier_slug`, 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: []
|
@@ -146,6 +146,7 @@ nav:
|
||||
- Parts:
|
||||
- Parts: part/index.md
|
||||
- Creating Parts: part/create.md
|
||||
- Importing Parts: part/import.md
|
||||
- Virtual Parts: part/virtual.md
|
||||
- Part Views: part/views.md
|
||||
- Tracking: part/trackable.md
|
||||
@@ -237,6 +238,7 @@ nav:
|
||||
- Report Mixin: plugins/mixins/report.md
|
||||
- Schedule Mixin: plugins/mixins/schedule.md
|
||||
- Settings Mixin: plugins/mixins/settings.md
|
||||
- Supplier Mixin: plugins/mixins/supplier.md
|
||||
- Transition Mixin: plugins/mixins/transition.md
|
||||
- URL Mixin: plugins/mixins/urls.md
|
||||
- User Interface Mixin: plugins/mixins/ui.md
|
||||
|
Reference in New Issue
Block a user