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

Add barcode generation capabilities to plugins #7648

Merged
merged 35 commits into from
Jul 22, 2024

Conversation

wolflu05
Copy link
Contributor

@wolflu05 wolflu05 commented Jul 14, 2024

This PR adds barcode generation capabilities to plugins which enables custom formats.

The current built-in inventreebarcode plugin is used to generate the already existing JSON barcode format, but can also generate the short format described in #6612 (comment) (depends on how the plugin is configured) (can also parse this short format).

The previous barcode implementation allowed to create a non-brief variant of qr_code data, which was not used anywhere except in some tests, so I dropped this for now since it was not touched too after the initial implementation 4 years ago. Please tell me if this is actually being used somewhere, then we need to find a different solution.

image

TODO

  • allow plugins to generate barcode data
  • inventreebarcode plugin implement parsing for short format
  • improve qr_code template tag to let the user specify the ECL
  • improve tests
  • improve docs
  • bump API version
  • PUI implement show QR code modal
  • CUI use correct format for QR code modal

Closes #6612

Copy link

netlify bot commented Jul 14, 2024

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

Name Link
🔨 Latest commit 3475637
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/669d5238937b450008e58ee9

Copy link

codecov bot commented Jul 14, 2024

Codecov Report

Attention: Patch coverage is 86.36364% with 36 lines in your changes missing coverage. Please review.

Project coverage is 83.68%. Comparing base (afad866) to head (3475637).
Report is 312 commits behind head on master.

Files with missing lines Patch % Lines
src/frontend/src/components/items/QRCode.tsx 14.28% 24 Missing ⚠️
src/frontend/src/components/buttons/CopyButton.tsx 40.00% 0 Missing and 3 partials ⚠️
src/backend/InvenTree/plugin/base/barcodes/api.py 92.00% 2 Missing ⚠️
...c/backend/InvenTree/plugin/base/barcodes/helper.py 94.73% 2 Missing ⚠️
...nTree/plugin/builtin/barcodes/inventree_barcode.py 93.33% 2 Missing ⚠️
src/backend/InvenTree/InvenTree/models.py 83.33% 1 Missing ⚠️
src/backend/InvenTree/common/models.py 83.33% 1 Missing ⚠️
...c/frontend/src/components/items/ActionDropdown.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7648      +/-   ##
==========================================
- Coverage   83.70%   83.68%   -0.03%     
==========================================
  Files        1105     1107       +2     
  Lines       48869    49057     +188     
  Branches     1576     1585       +9     
==========================================
+ Hits        40906    41051     +145     
- Misses       7548     7597      +49     
+ Partials      415      409       -6     
Flag Coverage Δ
backend 85.25% <96.46%> (+0.03%) ⬆️
pui 64.83% <26.31%> (-0.34%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wolflu05 wolflu05 added barcode Barcode scanning and integration plugin Plugin ecosystem report Report/Label generation labels Jul 15, 2024
@wolflu05 wolflu05 added this to the 0.16.0 milestone Jul 15, 2024
@wolflu05 wolflu05 marked this pull request as ready for review July 15, 2024 11:49
@wolflu05
Copy link
Contributor Author

This is ready for review now.

@matmair
Copy link
Member

matmair commented Jul 18, 2024

Very nice work; One small visual thing: Could we add some text above the barcode data so it is understandable what the barcode data is meant to be?

@SchrodingersGat
Copy link
Member

@matmair this text is available here, below the barcode: is this what you meant?

image

@wolflu05 tested locally and this seems to work very well. Short barcodes integrate nicely with the app :)

@wolflu05
Copy link
Contributor Author

wolflu05 commented Jul 19, 2024

Could we add some text above the barcode data so it is understandable what the barcode data is meant to be?

Added now. Also applied your code review comments.

Short barcodes integrate nicely with the app :)

Yes, that's a very good system. Very easily extendable through barcode parsing plugins. Great base work.

@SchrodingersGat
Copy link
Member

LGTM. @matmair any further thoughts on this?

@matmair
Copy link
Member

matmair commented Jul 20, 2024

LGTM, great work @wolflu05

@wolflu05 wolflu05 closed this Jul 20, 2024
@wolflu05 wolflu05 reopened this Jul 20, 2024
@wolflu05
Copy link
Contributor Author

wolflu05 commented Jul 20, 2024

Hm, the ci tests error seems strange, need to investigate that further tomorrow before we can merge this.

@wolflu05
Copy link
Contributor Author

Ok, figured it out. This is now ready to merge from my side. (For detailed explanation, see #7648 (comment) )

@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature feature api Relates to the API labels Jul 22, 2024
@SchrodingersGat
Copy link
Member

@wolflu05 very nice indeed. Thanks for your great work on this!

@SchrodingersGat SchrodingersGat merged commit 16e535f into inventree:master Jul 22, 2024
28 checks passed
@wolflu05 wolflu05 deleted the barcode-generation branch July 22, 2024 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Relates to the API barcode Barcode scanning and integration enhancement This is an suggested enhancement or new feature feature plugin Plugin ecosystem report Report/Label generation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Encode QR data more efficiently
3 participants