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
Refactor tables and API for reports and labels #5841
Maybe this could be structured as a generic similar to states - consistent code docstrings, fully covered with tests within the module. I would also remove the backend distinction between labels and reports and move everything into one new table to reduce duplications.
Regarding comments on other threads: I would like to see reports and labels kept separate. They are functionally different enough to warrant separate models and handling
Labels can be sent to specific external printers
Labels use width and height parameters
Reports specify page size i.e. A4 / Letter
Labels can be grouped together when printing (e.g. array onto a single sheet)
Happy to look at merging existing label tables together, as with merging existing report tables
@SchrodingersGat do you think this should also apply to the code/database level? We have a lot of duplication in this area currently. Nearly half of our Python code-duplication is between the label and report app and the differences in the API and database make it more difficult than it needs to be. All the things you describe could also be flags on the merged definition - that would also make it possible to use the templating functions more flexibly and document contexts, variables etc dynamically. The amount of support we have around this area is significant.
I would be for having all in one generic table and adding flags. Having different apis that have different interfaces leads to a lot of codeduplication and messy code on the frontend.
While implementing the template editor in the frontend I came up with a collection of things that we should consider now if we refactor that.
I think we should call them from now on templates that exist in different types (label, report), each having some different variants (e.g. labels: stock item, location, ... and report: bom, location, ...)
template attributes like width, height for labels and page size, orientation for reports (also at frontend level, how do we want to expose them via the api?)
it would be nice to have a generic interface that can later be extended by plugins to add custom types/variants
how do we handle template assets
how do we handle snippets generically, maybe we just add them as a third type next to labels, reports, ...?
we shouldn't store templates as files on the server, it would be good to keep them in the database
we should not differentiate between InvenTree templates and user defined templates like the current folder structure does. IMHO it is enough to just add the predefined templates on the first startup and then don't care what the user does with it. (currently if the user changes them they get added again on the next startup because they now no longer exist)
each variant should be able to define a custom context (later we should somehow be able to integrate that with the codeeditor), default template that will be used for each new template and some info about it that can be accessed via api
we should be able to render a template for a variant without uploading it as a template first, but instead use the post body (useful for previews)
Activity
matmair commentedon Nov 2, 2023
Supporting generic model relations would be nice, that way plugins could use reports easily.
github-actions commentedon Jan 2, 2024
This issue seems stale. Please react to show this is still important.
wolflu05 commentedon Jan 2, 2024
Still relevant
matmair commentedon Feb 20, 2024
Related #5884 #2777
matmair commentedon Feb 20, 2024
Maybe this could be structured as a generic similar to states - consistent code docstrings, fully covered with tests within the module. I would also remove the backend distinction between labels and reports and move everything into one new table to reduce duplications.
matmair commentedon Feb 20, 2024
Could also be part of #6417
SchrodingersGat commentedon Feb 24, 2024
Regarding comments on other threads: I would like to see reports and labels kept separate. They are functionally different enough to warrant separate models and handling
Happy to look at merging existing label tables together, as with merging existing report tables
matmair commentedon Feb 25, 2024
@SchrodingersGat do you think this should also apply to the code/database level? We have a lot of duplication in this area currently. Nearly half of our Python code-duplication is between the label and report app and the differences in the API and database make it more difficult than it needs to be. All the things you describe could also be flags on the merged definition - that would also make it possible to use the templating functions more flexibly and document contexts, variables etc dynamically. The amount of support we have around this area is significant.
wolflu05 commentedon Feb 25, 2024
I would be for having all in one generic table and adding flags. Having different apis that have different interfaces leads to a lot of codeduplication and messy code on the frontend.
While implementing the template editor in the frontend I came up with a collection of things that we should consider now if we refactor that.
matmair commentedon Feb 25, 2024
Maybe this should be a dev call and a task list
SchrodingersGat commentedon Feb 26, 2024
I'm keen to address this properly - a good target for the
0.15.0release I think. Let's revisit after0.14.0is out - I'd like to focus on that :)matmair commentedon Feb 26, 2024
Regarding templates in database we could either use https://django-dbtemplates.readthedocs.io/en/latest/; it is not Dj 4.2 ready but looks nice otherwise or roll our own based on it's idea https://github.com/jazzband/django-dbtemplates/blob/233a401e75d9b6133dd4c9fdc17bf85d2660cc41/dbtemplates/loader.py
SchrodingersGat commentedon Feb 26, 2024
@matmair interesting find!