Skip to content
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

Supplier integration #3791

Closed
wants to merge 151 commits into from
Closed

Conversation

matmair
Copy link
Member

@matmair matmair commented Oct 16, 2022

This PR:

  • GenericWebTransaction model
  • transitions WebhookMessage to GenericWebTransaction
  • Adds WebConnection (including admin, API)
  • Adds WebConnectionTransaction inheriting from GenericWebTransaction)
  • Adds ConnectionSetting (including API, admin)
  • Adds PluginSearch view (in the API) to search through connections and adds it to search
  • Adds SupplierMixin
  • Adds get_api_url method to PluginConfig model
  • Adds plugin_connections tag

Open:

  • tests for webconnections
  • tests for search API
  • API to add part from search result
  • tests for part add API
  • UI for adding part from search result

Before merge:

  • Move OAuth checks to mixin
  • Move requests middleware to mixin
  • Move WebConnectionData to plugin namespace
  • Move SearchRunResult to plugin namespace

Fixes parts of #3261

from plugin.plugin import InvenTreePlugin


class ConnectionSetting(common.models.BaseInvenTreeSetting):
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: This class needs some rework after merging master in (Ref: #4834 )

Copy link
Member Author

Choose a reason for hiding this comment

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

probably, a lot has changed in this area

@github-actions
Copy link
Contributor

This PR seems stale. Please react to show this is still important.

@github-actions github-actions bot added the inactive Indicates lack of activity label Jul 31, 2023
@wolflu05
Copy link
Contributor

wolflu05 commented Aug 2, 2023

I definitely want to have that feature, but currently the react refactor is in focus.

@github-actions github-actions bot removed the inactive Indicates lack of activity label Aug 3, 2023
30350n added a commit to 30350n/InvenTree that referenced this pull request Sep 6, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2023

This PR seems stale. Please react to show this is still important.

@github-actions github-actions bot added the inactive Indicates lack of activity label Oct 3, 2023
@matmair
Copy link
Member Author

matmair commented Oct 3, 2023

Still in the WIP pipeline

@github-actions github-actions bot removed the inactive Indicates lack of activity label Oct 4, 2023
@matmair matmair closed this Oct 10, 2023
@SchrodingersGat
Copy link
Member

@matmair I'm still very keen to see this implemented - do you have motivation on this still too? Does this in your mind require the react integration, or can we look at getting it merged in now?

@matmair
Copy link
Member Author

matmair commented Oct 11, 2023

I will move this to a plugin; it requires either the react integration or shipping the UI - which I will do with the plugin. Development velocity is also much easier to handle in a plugin.

@30350n
Copy link
Contributor

30350n commented Oct 11, 2023

How is that going to work then? Would this plugin basically enable the use of other supplier plugins? Or would it just be one big plugin supporting multiple suppliers?

Tbh I haven't really had time to look at this in depth yet, but I feel like it'd integrate well with what I've been working on in #5509 and the backend part should probably be in core ... buuut I really have no clue about the frontend requirements here. Could this maybe be divided into multiple smaller features/PRs?

Also, regarding actual supplier support: I've seen that you already have a WIP digikey plugin. I've been working on my own part importer script (basically a simplified/improved version of Ki-nTree, with proper support for nested categories). It's working quite well for my purposes, but I still feel like it shouldn't really be a script, but a plugin aswell, thus useable directly from the inventree interface. So I'd be interested in contributing that into core/your plugin aswell.

@matmair
Copy link
Member Author

matmair commented Oct 11, 2023

There will be a plugin that provides a basic UI and all that is required to handle the typical flows like search, data gathering, and creation of new parts/stock. I will not continue development with core as a target.

This plugin can be used as a target for vendor-specific APIs.

matmair added a commit to matmair/InvenTree that referenced this pull request Oct 18, 2023
commit f15dcfc
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Oct 18 16:52:07 2023 +0200

    Fix supplier plugins not inheriting from settings mixin

commit 36f4066
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Oct 17 15:55:52 2023 +0200

    Add SUPPLIER_ID setting to other suppliers

commit d46cc53
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Oct 17 15:49:15 2023 +0200

    Add DEFAULT_SUPPLIER_NAME to mouser plugin

commit c4c34b9
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Oct 17 15:48:51 2023 +0200

    Refactor get_supplier_parts to not use lists

commit d56c4bf
Author: Bobbe <maxschlecht@web.de>
Date:   Thu Oct 12 03:19:13 2023 +0200

    Try to retrigger pipeline

commit b6d685c
Author: Bobbe <maxschlecht@web.de>
Date:   Thu Oct 12 03:08:15 2023 +0200

    FIx TME barcode detection, Improve supplier barcode handling

commit c82baa2
Author: Bobbe <maxschlecht@web.de>
Date:   Thu Oct 12 02:33:31 2023 +0200

    Fix None type access

commit ed4dfff
Merge: d3e311e 0c519c6
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Oct 11 19:47:21 2023 +0200

    Merge remote-tracking branch 'origin/master' into vendor_barcodes

commit d3e311e
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Oct 11 19:46:00 2023 +0200

    Improve docstrings

commit f8f1eed
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Oct 11 19:29:33 2023 +0200

    Refactor get_supplier_parts, Add get_supplier method

commit 85351cf
Author: Bobbe <maxschlecht@web.de>
Date:   Thu Oct 5 01:14:46 2023 +0200

    Use Decimal instead of int for quantity

commit a45ba92
Merge: 85ace32 30cf97d
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Oct 3 03:52:56 2023 +0200

    Merge remote-tracking branch 'origin/master' into vendor_barcodes

commit 85ace32
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Oct 3 03:49:51 2023 +0200

    Fix TME qrcode regex

commit d0b1acf
Merge: 584eb0f 352fb4f
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Oct 3 03:08:35 2023 +0200

    Merge remote-tracking branch 'origin/master' into vendor_barcodes

commit 584eb0f
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Oct 3 03:06:18 2023 +0200

    Add documentation for this feature

commit bab4614
Author: Bobbe <maxschlecht@web.de>
Date:   Mon Oct 2 20:08:49 2023 +0200

    Fix TME qrcode regex

commit 7e8abcb
Author: Bobbe <maxschlecht@web.de>
Date:   Mon Oct 2 03:21:15 2023 +0200

    Fix TME purchase order number

commit fadcea2
Author: Bobbe <maxschlecht@web.de>
Date:   Mon Oct 2 03:05:33 2023 +0200

    Add back all tests again

commit 09ffc34
Author: Bobbe <maxschlecht@web.de>
Date:   Mon Oct 2 03:05:06 2023 +0200

    Add TME tests again

commit c7f5521
Merge: 7b6855d e767516
Author: Bobbe <maxschlecht@web.de>
Date:   Mon Oct 2 02:42:55 2023 +0200

    Merge remote-tracking branch 'origin/master' into vendor_barcodes

commit 7b6855d
Author: Bobbe <maxschlecht@web.de>
Date:   Mon Oct 2 00:45:25 2023 +0200

    If this works the tests are broken, if this doesn't work the tests are broken too

commit 32916e9
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 20:14:51 2023 +0200

    Remove the TME tests again

commit 0390373
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 19:34:02 2023 +0200

    Add TME supplier barcode plugin

commit 5970947
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 19:33:25 2023 +0200

    Add SupplierBarcodeMixin to minimize shared code between plugins

commit 9d13c27
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 19:28:12 2023 +0200

    Disable the test again

commit 91bad76
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 18:26:50 2023 +0200

    Try deleting the stock item and stock locations

commit 50082ae
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 17:51:03 2023 +0200

    Test 4th receive test with debug prints

commit b241b50
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 16:57:46 2023 +0200

    Test third receive test

commit 9337345
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 16:21:31 2023 +0200

    Test second receive test

commit f7e6a82
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 15:49:43 2023 +0200

    Test with even more receive tests

commit 85841df
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 14:34:34 2023 +0200

    Test with simple receive test

commit 0e63ef4
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 01:29:11 2023 +0200

    Test with simple tests

commit 8eaabc9
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 00:56:24 2023 +0200

    Test again without tests

commit 72536e9
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Oct 1 00:30:17 2023 +0200

    Test with all plugins, but without mouser "model" setting

commit f1ba184
Author: Bobbe <maxschlecht@web.de>
Date:   Sat Sep 30 18:25:26 2023 +0200

    Test only with digikey plugin

commit 65b4175
Author: Bobbe <maxschlecht@web.de>
Date:   Sat Sep 30 18:04:10 2023 +0200

    Test removing all plugins

commit b47c6eb
Author: Bobbe <maxschlecht@web.de>
Date:   Sat Sep 30 17:14:14 2023 +0200

    Fix pre formatted log messages

commit efe2aac
Merge: a1dc0eb 3cd7ee9
Author: Bobbe <maxschlecht@web.de>
Date:   Sat Sep 30 17:00:48 2023 +0200

    Merge remote-tracking branch 'origin/master' into vendor_barcodes

commit a1dc0eb
Author: Bobbe <maxschlecht@web.de>
Date:   Sat Sep 30 17:00:33 2023 +0200

    Remove the test print again

commit bc82ee3
Merge: 8b461c4 6f70f6d
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 20 01:40:40 2023 +0200

    Merge remote-tracking branch 'origin/master' into vendor_barcodes

commit 8b461c4
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Sep 19 21:53:36 2023 +0200

    Add debug print to investigate why tests are failing

commit 2e0be5a
Merge: 420700f 314c93d
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Sep 19 08:52:29 2023 +0200

    Merge remote-tracking branch 'origin/master' into vendor_barcodes

commit 420700f
Author: Bobbe <maxschlecht@web.de>
Date:   Sat Sep 16 13:22:54 2023 +0200

    Fix error if no line item exists

commit 6db49ca
Author: Bobbe <maxschlecht@web.de>
Date:   Fri Sep 15 17:19:50 2023 +0200

    Add new api version for this PR

commit fa9b524
Merge: a76df6c 2be2ea4
Author: Bobbe <maxschlecht@web.de>
Date:   Fri Sep 15 17:15:53 2023 +0200

    Merge remote-tracking branch 'origin/master' into vendor_barcodes

commit a76df6c
Author: Bobbe <maxschlecht@web.de>
Date:   Fri Sep 15 17:14:51 2023 +0200

    Improve selection of line item, if multiple line items match the SKU

commit cdef246
Author: Bobbe <maxschlecht@web.de>
Date:   Fri Sep 15 00:58:42 2023 +0200

    Refactor a bunch of checks

commit 35dc310
Author: Bobbe <maxschlecht@web.de>
Date:   Fri Sep 15 00:49:54 2023 +0200

    Improve model access using first() in two places

commit 46ca6df
Author: Bobbe <maxschlecht@web.de>
Date:   Fri Sep 15 00:49:24 2023 +0200

    Clarify return type for scan_receive_item

commit 6419779
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 13 11:13:04 2023 +0200

    Fix naming clash

commit 08a2507
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 13 10:24:51 2023 +0200

    Add get_supplier_part helper, check for barcode_data being a str

commit a23caef
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 13 09:40:01 2023 +0200

    Fix type annotations for python 3.8

commit 1d349f0
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 13 09:30:57 2023 +0200

    Fix fomatting again

commit cd35744
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Sep 12 15:38:13 2023 +0200

    Use part.get_default_location() instead of part.default_location

commit 9a3c968
Author: Bobbe <maxschlecht@web.de>
Date:   Mon Sep 11 03:36:59 2023 +0200

    FIx quantity and location not being in lineitem reponse

commit a84cea6
Author: Bobbe <maxschlecht@web.de>
Date:   Mon Sep 11 02:09:54 2023 +0200

    Check if barcode has already been assigned, Fix tests

commit 14ccd87
Author: Bobbe <maxschlecht@web.de>
Date:   Mon Sep 11 01:51:06 2023 +0200

    Fix location in response, only include quantity and location if set

commit bff393a
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Sep 10 21:20:44 2023 +0200

    Always include lineitem in api response

commit 13e7424
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Sep 10 17:31:12 2023 +0200

    Implement the api-barcode-po-receive endpoint for all suppliers

commit c97ef6e
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Sep 10 17:10:08 2023 +0200

    Refactor supplier_barcode.py helpers into BarcodeMixin

commit 3f08b3e
Author: Bobbe <maxschlecht@web.de>
Date:   Sun Sep 10 16:46:44 2023 +0200

    Add api-barcode-po-receive endpoint

commit b730a50
Author: Bobbe <maxschlecht@web.de>
Date:   Thu Sep 7 13:38:47 2023 +0200

    Add barcode integration tests

commit a7840cf
Author: Bobbe <maxschlecht@web.de>
Date:   Thu Sep 7 00:36:00 2023 +0200

    Improve formatting

commit acb1179
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 6 13:58:18 2023 +0200

    Add __init__.py to suppliers directory

commit 1f62302
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 6 13:47:57 2023 +0200

    Add get_supplier_part helper, Refactor plugins in preparation for inventree#3791

commit df885c2
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 6 12:52:06 2023 +0200

    Move barcode plugins to new suppliers subdirectory

commit a88eb74
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 6 12:39:09 2023 +0200

    Add lcsc barcode support

commit 9832e73
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 6 10:03:33 2023 +0200

    Use model instead of name for mouser supplier, add auto detection magic

commit f135019
Author: Bobbe <maxschlecht@web.de>
Date:   Wed Sep 6 00:34:27 2023 +0200

    Separate out ecia 2d barcode parser, Add quantity, PO number to response

commit d00c486
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Sep 5 20:57:09 2023 +0200

    made small style cleanups

commit e9224bd
Author: Matthias Mair <code@mjmair.com>
Date:   Tue Sep 5 20:45:05 2023 +0200

    added small fixes if no part is found

commit b5facf4
Author: Bobbe <maxschlecht@web.de>
Date:   Tue Sep 5 13:20:31 2023 +0200

    Add support for scanning digikey and mouser barcodes
SchrodingersGat pushed a commit that referenced this pull request Oct 19, 2023
* Add support for scanning digikey and mouser barcodes

* added small fixes if no part is found

* made small style cleanups

* Separate out ecia 2d barcode parser, Add quantity, PO number to response

* Use model instead of name for mouser supplier, add auto detection magic

* Add lcsc barcode support

* Move barcode plugins to new suppliers subdirectory

* Add get_supplier_part helper, Refactor plugins in preparation for #3791

* Add __init__.py to suppliers directory

* Improve formatting

* Add barcode integration tests

* Add api-barcode-po-receive endpoint

* Refactor supplier_barcode.py helpers into BarcodeMixin

* Implement the api-barcode-po-receive endpoint for all suppliers

* Always include lineitem in api response

* Fix location in response, only include quantity and location if set

* Check if barcode has already been assigned, Fix tests

* FIx quantity and location not being in lineitem reponse

* Use part.get_default_location() instead of part.default_location

* Fix fomatting again

* Fix type annotations for python 3.8

* Add get_supplier_part helper, check for barcode_data being a str

* Fix naming clash

* Clarify return type for scan_receive_item

* Improve model access using first() in two places

* Refactor a bunch of checks

* Improve selection of line item, if multiple line items match the SKU

* Add new api version for this PR

* Fix error if no line item exists

* Add debug print to investigate why tests are failing

* Remove the test print again

* Fix pre formatted log messages

* Test removing all plugins

* Test only with digikey plugin

* Test with all plugins, but without mouser "model" setting

* Test again without tests

* Test with simple tests

* Test with simple receive test

* Test with even more receive tests

* Test second receive test

* Test third receive test

* Test 4th receive test with debug prints

* Try deleting the stock item and stock locations

* Disable the test again

* Add SupplierBarcodeMixin to minimize shared code between plugins

* Add TME supplier barcode plugin

* Remove the TME tests again

* If this works the tests are broken, if this doesn't work the tests are broken too

* Add TME tests again

* Add back all tests again

* Fix TME purchase order number

* Fix TME qrcode regex

* Add documentation for this feature

* Fix TME qrcode regex

* Use Decimal instead of int for quantity

* Refactor get_supplier_parts, Add get_supplier method

* Improve docstrings

* Fix None type access

* FIx TME barcode detection, Improve supplier barcode handling

* Try to retrigger pipeline

* Refactor get_supplier_parts to not use lists

* Add DEFAULT_SUPPLIER_NAME to mouser plugin

* Add SUPPLIER_ID setting to other suppliers

* Fix supplier plugins not inheriting from settings mixin

---------

Co-authored-by: Matthias Mair <code@mjmair.com>
@matmair matmair deleted the supplier-integration branch November 27, 2023 21:15
@nikolai2111
Copy link

Is there a better / recent setup guide than this #3791 (comment)?

In my current setup there is only one setting available and it's called "Supplier - The Supplier which acts as 'DigiKey'".

@matmair
Copy link
Member Author

matmair commented Jan 30, 2024

This PR is closed, development of this was shifted and none of the linked components are finished. I refactored basically the whole thing, some of the decisions made here were not scalable enough.

@30350n
Copy link
Contributor

30350n commented Jan 30, 2024

In my current setup there is only one setting available and it's called "Supplier - The Supplier which acts as 'DigiKey'".

That's from the supplier barcode plugins (introduced in #5509).

@nikolai2111
Copy link

Ah I see, I thought it was the same thing.
So there won't be a native DigiKey plugin?

Thanks for the info.

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 plugin Plugin ecosystem user interface User interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants