You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Report] Generate single report against selected items #9423
Originally posted by tristanle22 March 30, 2025
I want to select a few stock items and generate a report. In the report, I want to have a table, with each row for each stock item. I can't find a context variable that represents a list of selected stock items.
I'm aware of the built-in "Inventree Test Report" generates a new page for each selected item.
Feature Description
Instead of generating a separate report for each individually selected item (e.g. stock item / order / part), add an option to pass all selected items through to the report context, and then generate a single report from that.
Implementation Ideas
Add a "merge" (or similar named) field to the "ReportTemplate" model
This allows the report template creator to decide whether the report is generated against a single output, or against all selected outputs
The ReportTemplate model has an existing print method which could be overloaded:
I'm working on this feature. Just have a dump question as I'm not very familiar with the matter :). Currently I'm adding the "merge" field as a Boolean. If the user want to set this field (or any other field) to True in the report template, how would they do it?
Thanks @SchrodingersGat for the instructions! I have followed your steps above. After making the changes, I ran debug with vscode, however, the new field doesn't show up. Is anything else I need to do before running?
From a quick search, this autogenerated field is missing the new field: src/backend/InvenTree/report/migrations/0022_reporttemplate.py. Not sure if it has any signficance.
And then access at http://localhost:5173
No I didn't do anything "non-standard", beside having to manually install psycopg since it was missing from src/backend/requirements.txt. After restarting the devcontainer docker image, I was able to login to localhost:5173.
Activity
SchrodingersGat commentedon Mar 31, 2025
@tristanle22 FYI
tristanle22 commentedon Apr 3, 2025
I'm working on this feature. Just have a dump question as I'm not very familiar with the matter :). Currently I'm adding the "merge" field as a Boolean. If the user want to set this field (or any other field) to True in the report template, how would they do it?
SchrodingersGat commentedon Apr 3, 2025
@tristanle22 great question. Here's a rough sequence of required steps:
ReportTemplatemodelInvenTree/src/backend/InvenTree/report/models.py
Line 330 in 67bdf31
invoke migrateAdd the new field name to the
Meta.fieldsattribute of theReportTemplateSerializerclassInvenTree/src/backend/InvenTree/report/serializers.py
Line 61 in 67bdf31
This will ensure that the new field is exposed to the API
Add your new field name to the
additionalFormFieldsattribute of theReportTemplateTablecomponent:InvenTree/src/frontend/src/pages/Index/Settings/AdminCenter/ReportTemplatePanel.tsx
Line 7 in 67bdf31
That should be sufficient to allow the user to edit this new field. LMK how you go!
tristanle22 commentedon Apr 3, 2025
Thanks @SchrodingersGat for the instructions! I have followed your steps above. After making the changes, I ran debug with vscode, however, the new field doesn't show up. Is anything else I need to do before running?
From a quick search, this autogenerated field is missing the new field: src/backend/InvenTree/report/migrations/0022_reporttemplate.py. Not sure if it has any signficance.
SchrodingersGat commentedon Apr 3, 2025
In vscode you'll need two processes running:
Backend Server
invoke dev.serverFrontend Dev Server (with auto-reload)
invoke dev.frontend-serverAnd then access at
http://localhost:5173tristanle22 commentedon Apr 6, 2025
Ah I see. Thanks for your help! I can see the changes in the front end now.
tristanle22 commentedon Apr 8, 2025
After running dev.setup-test to load the sample dataset, I was able to login to http://localhost:8000 with user 'admin' and pw 'inventree'. However, the same credentials didn't work on http://localhost:5173. Do you have any idea why? @SchrodingersGat
SchrodingersGat commentedon Apr 8, 2025
Probably due to CORS issues - have a look at the network response in your browser when you try to login.
By default the devcontainer setup should work seamlessly with the
localhost:5173- have you done anything "non-standard" in your setup?tristanle22 commentedon Apr 9, 2025
No I didn't do anything "non-standard", beside having to manually install psycopg since it was missing from src/backend/requirements.txt. After restarting the devcontainer docker image, I was able to login to localhost:5173.