Skip to content

[Report] Generate single report against selected items #9423

Description

@SchrodingersGat

Discussed in #9408

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:

def print(self, items: list, request=None, output=None, **kwargs) -> DataOutput:

Simply replace this iterator:

for instance in items:

Activity

  1. added
    enhancement
    report
    on Mar 31, 2025
  2. added this to the 1.0.0 milestone on Mar 31, 2025
  3. SchrodingersGat commented on Mar 31, 2025

    @SchrodingersGat
    MemberAuthor
  4. tristanle22 commented on Apr 3, 2025

    @tristanle22
    Contributor

    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?

  5. SchrodingersGat commented on Apr 3, 2025

    @SchrodingersGat
    MemberAuthor

    @tristanle22 great question. Here's a rough sequence of required steps:

    1. Add new field to ReportTemplate model

    class ReportTemplate(TemplateUploadMixin, ReportTemplateBase):

    1. Run database migrations (to actually add the new field)

    invoke migrate

    1. Expose new field to the API

    Add the new field name to the Meta.fields attribute of the ReportTemplateSerializer class

    class ReportTemplateSerializer(ReportSerializerBase):

    This will ensure that the new field is exposed to the API

    1. Add the new field to the frontend form

    Add your new field name to the additionalFormFields attribute of the ReportTemplateTable component:

    That should be sufficient to allow the user to edit this new field. LMK how you go!

  6. tristanle22 commented on Apr 3, 2025

    @tristanle22
    Contributor

    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.

  7. SchrodingersGat commented on Apr 3, 2025

    @SchrodingersGat
    MemberAuthor

    I ran debug with vscode

    In vscode you'll need two processes running:

    Backend Server

    invoke dev.server

    Frontend Dev Server (with auto-reload)

    invoke dev.frontend-server

    And then access at http://localhost:5173

  8. tristanle22 commented on Apr 6, 2025

    @tristanle22
    Contributor

    Ah I see. Thanks for your help! I can see the changes in the front end now.

  9. tristanle22 commented on Apr 8, 2025

    @tristanle22
    Contributor
  10. SchrodingersGat commented on Apr 8, 2025

    @SchrodingersGat
    MemberAuthor

    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?

  11. tristanle22 commented on Apr 9, 2025

    @tristanle22
    Contributor

    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.

  12. marked [FR] Report for all Parts #9774 as a duplicate of this issue on Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementfeaturereport

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions