Skip to content

Report merge - #9532

Merged
SchrodingersGat merged 49 commits into
inventree:masterfrom
tristanle22:report_merge
Jun 20, 2025
Merged

SchrodingersGat merged 49 commits into
inventree:masterfrom
tristanle22:report_merge

Conversation

@tristanle22

@tristanle22 tristanle22 commented Apr 18, 2025 •

Copy link
Copy Markdown
Contributor

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

Closes #9423

@netlify

netlify Bot commented Apr 18, 2025 •

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit b8b9bf2
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6854c75fb5b6cb00087a7d79
😎 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: 96 (🔴 down 1 from production)
Accessibility: 81 (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.

Comment thread .pre-commit-config.yaml Resolved
Comment thread src/backend/InvenTree/report/models.py Resolved
Comment thread src/backend/InvenTree/report/models.py Resolved
@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

matmair commented Apr 18, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor 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

matmair commented Apr 18, 2025

Copy link
Copy Markdown
Member

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

@SchrodingersGat

Copy link
Copy Markdown
Member

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

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good reduction of duplicates

Comment thread src/backend/InvenTree/report/models.py Resolved
Comment thread src/backend/InvenTree/report/models.py Resolved
@matmair

matmair commented Apr 21, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor 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

matmair commented Apr 22, 2025

Copy link
Copy Markdown
Member

Both correct @tristanle22

@tristanle22

Copy link
Copy Markdown
Contributor Author

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

@SchrodingersGat

Copy link
Copy Markdown
Member

@codecov

codecov Bot commented Apr 23, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.57%. Comparing base (45daef8) to head (b8b9bf2).
⚠️ Report is 319 commits behind head on master.

Files with missing lines Patch % Lines
src/backend/InvenTree/report/models.py 83.63% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9532      +/-   ##
==========================================
+ Coverage   86.56%   86.57%   +0.01%     
==========================================
  Files        1242     1243       +1     
  Lines       54698    54752      +54     
  Branches     2234     2234              
==========================================
+ Hits        47348    47402      +54     
  Misses       6782     6782              
  Partials      568      568              
Flag Coverage Δ
backend 88.52% <88.00%> (+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.

@matmair

matmair commented Jun 11, 2025

Copy link
Copy Markdown
Member

@SchrodingersGat I have resolved the conflicts

@SchrodingersGat

Copy link
Copy Markdown
Member

Documentation

The "merge" feature needs some clearer documentation in the "report" page (./docs/docs/report/report.md).

In particular, the difference in terminology in the report template, e.g. use instance.<name> instead of <name>

Functionality

On testing, it appears to work as expected, nice!

@tristanle22

Copy link
Copy Markdown
Contributor Author

Documentation

The "merge" feature needs some clearer documentation in the "report" page (./docs/docs/report/report.md).

In particular, the difference in terminology in the report template, e.g. use instance.<name> instead of <name>

Functionality

On testing, it appears to work as expected, nice!

I have a section in .docs/docs/report/context_variables.md that explains what you mentioned. I can make it clearer there, instead of in ./docs/docs/report/report.md

@wolflu05 wolflu05 mentioned this pull request Jun 13, 2025
1 of 2 tasks
@SchrodingersGat

Copy link
Copy Markdown
Member

I would still like to see some more obvious callout from the main report docs page :)

@SchrodingersGat

Copy link
Copy Markdown
Member

@tristanle22 if you can address the documentation, resolve conflicts and look at the failing tests, I'd love to see this merged!

@tristanle22

Copy link
Copy Markdown
Contributor Author

Sorry, I've been occupied lately. Will try to resolve the last two items.

@tristanle22

Copy link
Copy Markdown
Contributor Author

All failing tests are because of the same error:
FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/work/InvenTree/media/data_output/output.html'
This is how I'm grabbing the output html. It worked locally:
report_path = os.path.join( settings.MEDIA_ROOT.parent, response.data['output'].lstrip('/') )

@SchrodingersGat Do you have any suggestion?

@SchrodingersGat

Copy link
Copy Markdown
Member

All failing tests are because of the same error: FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/work/InvenTree/media/data_output/output.html' This is how I'm grabbing the output html. It worked locally: report_path = os.path.join( settings.MEDIA_ROOT.parent, response.data['output'].lstrip('/') )

@SchrodingersGat Do you have any suggestion?

It should not be MEDIA_ROOT.parent - this is up one level from the media dir. I think it should be settings.MEDIA_ROOT instead

@tristanle22

tristanle22 commented Jun 20, 2025 •

Copy link
Copy Markdown
Contributor Author

All failing tests are because of the same error: FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/work/InvenTree/media/data_output/output.html' This is how I'm grabbing the output html. It worked locally: report_path = os.path.join( settings.MEDIA_ROOT.parent, response.data['output'].lstrip('/') )
@SchrodingersGat Do you have any suggestion?

It should not be MEDIA_ROOT.parent - this is up one level from the media dir. I think it should be settings.MEDIA_ROOT instead

It has to be MEDIA_ROOT.parent because:

print(response.data['output']
> /media/data_output/output_qXuMPAB.html

@SchrodingersGat

Copy link
Copy Markdown
Member

Ah, ok so the "response" object provides the path to the file on the web server - NOT where the file resides on disk.

So, the inventree server provides the output at /media/data_output/some_file.pdf' - which is a path relative to the host.

On disk, it will be somewhere like /my/path/to/inventree-media/data_output/some_file.pdf/

So, take the response path, strip the /media/ off the start, and then join that the MEDIA_ROOT

@SchrodingersGat

Copy link
Copy Markdown
Member

@tristanle22 thanks for implementing this, it's a great addition! Very nice work :)

@SchrodingersGat
SchrodingersGat merged commit 786b52d into inventree:master Jun 20, 2025
@SchrodingersGat SchrodingersGat added feature api Relates to the API migration Data or schema migrations labels Jun 20, 2025
@tristanle22

Copy link
Copy Markdown
Contributor Author

Thanks @SchrodingersGat and @matmair for all the help! :)

@tristanle22 tristanle22 mentioned this pull request Jul 29, 2025
26 tasks done
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 feature migration Data or schema migrations 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