Skip to content

Report merge #9532

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
wants to merge 36 commits into
base: master
Choose a base branch
from
Open

Report merge #9532

wants to merge 36 commits into from

Conversation

tristanle22
Copy link

@tristanle22 tristanle22 commented Apr 18, 2025

Allow generation of a signle report PDF when multiple items are selected.

Closes #9423

Copy link

netlify bot commented Apr 18, 2025

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 33af985
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/682b6f9ee40053000894ae7e
😎 Deploy Preview https://deploy-preview-9532--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 94 (🔴 down 2 from production)
Accessibility: 89 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@matmair matmair added enhancement This is an suggested enhancement or new feature report Report/Label generation labels Apr 18, 2025
@matmair matmair added this to the 1.0.0 milestone Apr 18, 2025
@matmair
Copy link
Contributor

matmair commented Apr 18, 2025

As the API schema is changed you will also need to change the API version - see https://docs.inventree.org/en/stable/develop/contributing/#api-versioning

Let me know if you want more detailed pointers

@tristanle22
Copy link
Author

As the API schema is changed you will also need to change the API version - see https://docs.inventree.org/en/stable/develop/contributing/#api-versioning

Let me know if you want more detailed pointers

Is it just simply updating "src/backend/InvenTree/InvenTree/api_version.py" by bumping up the version and add a new line to INVENTREE_API_TEXT?

@matmair
Copy link
Contributor

matmair commented Apr 18, 2025

Yes; Just copy the latest entry and adjust to fit this PR (especially the url)

@SchrodingersGat
Copy link
Member

@tristanle22 a great start here :) Please begin by addressing the issues raised by @matmair

Copy link
Contributor

@matmair matmair left a comment

Choose a reason for hiding this comment

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

good reduction of duplicates

@matmair
Copy link
Contributor

matmair commented Apr 21, 2025

Looks pretty good now; it mainly is missing the migration I mentioned above and a bit of unit-testing to ensure your changes continue to work in the future;
Do you want pointers to those topics?

@tristanle22
Copy link
Author

@matmair For migration, there are some new Python files generated in src/backend/InvenTree/report/migrations/ after running invoke migrate, I guess they need to be included in this PR? For the testing part, I'm guessing the report unit tests live here src/backend/InvenTree/report/tests.py?

@matmair
Copy link
Contributor

matmair commented Apr 22, 2025

Both correct @tristanle22

@tristanle22
Copy link
Author

Is there a way to run src/backend/InvenTree/report/tests.py with VSCode debugger?

@SchrodingersGat
Copy link
Member

https://docs.inventree.org/en/latest/develop/contributing/?h=dev.test#run-tests-locally

In your case

invoke dev.test -r report.tests

Copy link

codecov bot commented Apr 23, 2025

Codecov Report

Attention: Patch coverage is 82.08955% with 12 lines in your changes missing coverage. Please review.

Project coverage is 86.36%. Comparing base (e0acfaa) to head (c5eb102).

Files with missing lines Patch % Lines
src/backend/InvenTree/report/models.py 82.00% 9 Missing ⚠️
src/backend/InvenTree/report/tests.py 72.72% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9532   +/-   ##
=======================================
  Coverage   86.35%   86.36%           
=======================================
  Files        1229     1230    +1     
  Lines       53968    54014   +46     
  Branches     2260     2260           
=======================================
+ Hits        46604    46647   +43     
- Misses       6792     6795    +3     
  Partials      572      572           
Flag Coverage Δ
backend 88.32% <82.08%> (+<0.01%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SchrodingersGat
Copy link
Member

@tristanle22 some further things I would like to see here:

Migrations

You have a two migrations here, 0030 and 0031.

  • 0030 shadows an existing migration
  • 0031 simply combines the two "0030" migrations

Can you please delete 0031, and rename 0030 to 0031.

Unit Testing

Your unit testing does not actually test for multiple items being combined into a single report as you only send it a single item.

I would suggest that your unit test needs to:

  • Supply multiple items
  • Ensure that the report output generates a single report, not multiple reports stacked together
  • You can utilize the "DEBUG MODE" for reports here to return HTML and then you can read the HTML to ensure it is formatting properly

Documentation

Please add some documentation (in ./docs/) for this new feature:

  • What the "merge" feature does, and how to use it
  • How to specify which report templates get merged

@tristanle22
Copy link
Author

https://docs.inventree.org/en/latest/develop/contributing/?h=dev.test#run-tests-locally

In your case

invoke dev.test -r report.tests

I setup this command in launch.json, but it doesn't stop at any breakpoints. I want to place breakpoints to play around with the variables to see how the pieces work together. Do you have any suggestions?

@matmair
Copy link
Contributor

matmair commented Apr 28, 2025

There is a pre-defined launch definition for this provided in the code base, check out the launch.json file

@matmair
Copy link
Contributor

matmair commented May 1, 2025

@tristanle22 looking good; could you resolve the merge conflict so we can do a final review round?

@wolflu05
Copy link
Member

wolflu05 commented May 1, 2025

Do I understand it correct, that now we have another "dimension" of possible context generation in a matrix.

So now we have different contexts for:

  • type: label / report
  • component: part, stocklocation, ...
  • merged report: true, false

=> 2 * (~9) * 2 = ~36 different context combinations

Meaning if merge is set, all instance specific context is available in instances.x.<name> instead of <name>, but e.g. width (for labels) is still available as width and not instances.x.width ?

Just asking, because I have to adjust my LSP plugin accoringly now.

@tristanle22
Copy link
Author

Do I understand it correct, that now we have another "dimension" of possible context generation in a matrix.

So now we have different contexts for:

  • type: label / report
  • component: part, stocklocation, ...
  • merged report: true, false

=> 2 * (~9) * 2 = ~36 different context combinations

Meaning if merge is set, all instance specific context is available in instances.x.<name> instead of <name>, but e.g. width (for labels) is still available as width and not instances.x.width ?

Just asking, because I have to adjust my LSP plugin accoringly now.

Yes both correct

@tristanle22
Copy link
Author

@SchrodingersGat @matmair I think it's ready for a final round of review. Let me know if there's anything else you'd like to add/updated!

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 report Report/Label generation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Report] Generate single report against selected items
4 participants