Repository navigation
Closed
Labels
Description
Please verify that this feature request has NOT been suggested before.
- I checked and didn't find a similar feature request
Problem statement
The current label printing system is not very scalable in larger environments with multiple printers of the same brand because each plugin only has the ability to expose one printer.
Suggested solution
The current system has a huge downside. Every plugin can only provide one printer. I thought very long about how we can fix that system without the downsides listed in alternatives I've already considered. This is my final concept:
💡 The idea
- We add a new
PrintingDriverMixinwhich lets the developer define needed settings for each (physical) printer. That should work somehow the same way as the currentSettingsMixin, but is scoped to a specific (physical) printer - InvenTree settings get a new Tab
Printersto manage printers. We should think about a printing plugin more like a provided printing driver than just a function. In that tab we can manage printers. A printer has the following attributes:- name
- driver (select field - plugin that provides that driver)
- defined config for that specific printer (specified in 1)
- (scopes)
- ...
- We add printers by giving it a name, selecting a driver and fill out the driver specific settings
- When printing we can choose between all created printers. The printing plugin then gets called with the pdf that needs to be printed and the Printer model which contains the printer specific settings.
This changes the way printing plugins work, so we need some migration period to allow the migrating of the old LabelPrintingMixin plugins.
🚀 Future ideas
This enables us much more possibilities in the future:
- printers can be sorted based on priority for a specific label that need to be printed (e.g. that paper box labels are printed with a different printer than labels for magazine boxes)
- printers can be scoped to locations, categories, ... (you're most like not using a printer that is in Fab1 while you are in Fab2)
👍 Advantages
- ✅ Easily scaleable for large environments
- ✅ Not every developer has to think about handling multiple printers on themself
Describe alternatives you've considered
- Allow plugins to be instantiated multiple times with different settings (Ref: [FR] Create multiple instances of a plugin #3568)
- ❌ not very durable and can cause many bugs
- Allow plugins to expose multiple printers
- ❌ every printer plugin dev needs to handle multiple printers support on their own
Examples of other systems
No response
Do you want to develop this?
- I want to develop this.
Reacted by Matthias Mair
Activity
SchrodingersGat commentedon May 8, 2023
On the face of it, this approach seems a bit "heavy handed". For discussion, I'd like to propose a simpler alternative.
Each
LabelPrintingMixinplugin exposes a methodget_printers()which returns a list of names of available printers. These can be enumerated in whatever way the individual plugin wants. By default, theget_printers()plugin returns a single printer, as the current implementation, so existing printer plugins are not impacted.So a plugin may decide it wants to expose multiple printers, and can also decide how to name them for the user to select. Then the printers are exposed to the user in the current fashion.
This does not provide advanced functionality like print queues / scopes / advanced generic configuration. But it would be much simpler to implement.
I'm not sure how much effort to put into advanced printing functionality - how widely is this being used?
wolflu05 commentedon May 8, 2023
I also considered this approach (Alternative 2), but the big downside is that every plugin dev has to deal with the same problem. Every developer has to somehow save the available printers in the database create an own user interface for managing printers which can be different from plugin to plugin. Also scopes and filtering will be much more difficult to implement. I like the centralized idea so I would like to try work on implementing my suggested solution if you think this is just not prio for you but also like the idea. But I'm curious what matmair thinks. Because I think printing is one of the key functionalities of inventree.
matmair commentedon May 8, 2023
I would like to have proper machine (in this case printers) management and would like to work on this if @wolflu05 is not taking dips. A first implementation could be pretty simple. I am imagining something like the notification method registry. That works pretty great IMO. Something like this but for machines, with plugins providing drivers for the different machines. The new printing plugin would then implement a base LabelPrintingDriver - who's core function is the same printing function as current. The internal APIs from other parts of InvenTree need to change very little to support this.
The steps for implementing this would be:
@SchrodingersGat what do you think?
matmair commentedon May 8, 2023
Suggested name change by @wolflu05 is 'Driver' - which I find more fitting than Macine. The function remains the same. I edited my suggestion acordingly.
wolflu05 commentedon May 8, 2023
(quoted sentences are answers from @matmair )
wolflu05 commentedon May 8, 2023
new question
6.Where do you want that implementation to live? Distributed via pypi? What are the advantages, that would complicate things more I guess. Shouldn't that be its own Django app in core?
matmair commentedon May 8, 2023
Machine=> 1 instance (in database) of a thing that needs aDriverthat facilitates communication between the InventreeMachineand real-worldMachineie thingNew Question
SchrodingersGat commentedon May 9, 2023
As discussed over on discord, @wolflu05 if you want to take the lead on this I'd be happy to review and assist :)
wolflu05 commentedon May 9, 2023
I'd made a first interactive (click on the add printer button) draft with penpot of how the userinterface could look like. What approach do you think would be the best (V1,V2 or V3)? (Versions can be selected in the top bar)
I also thought a bit more about the plugin system implementation and think that the current mixins doesn't make sense to be used with a machine, which would enable use to only discover drivers and there is no need to activate them like a plugin inoder to see them appearing in the machine driver selection. So the
InvenTreePluginclass is not needed for a machine. I image the API like the following. What do you think?matmair commentedon May 9, 2023
@wolflu05 nice tool. I think V1 is the cleanes / easiest to work with.
As for the python code: I think the notification methods are pretty much how it could work. So a plugin would hold 1+ Drivers, discovered via inheritance. Maybe take a look at this. I think Drivers could work this way. That would enable global settings for a driver (via plugin settings) and per-machine settings.
wolflu05 commentedon May 10, 2023
This is much better. Thank you I'll take a look at that part - haven't looked into notifications yet.
6 remaining items
github-actions commentedon Sep 9, 2023
This issue seems stale. Please react to show this is still important.
wolflu05 commentedon Sep 9, 2023
In development at #4824, currently waiting on PUI and a few missing methods in the form framework.
github-actions commentedon Nov 9, 2023
This issue seems stale. Please react to show this is still important.
wolflu05 commentedon Nov 9, 2023
Currently in development and making some progress with the Machine admin in PUI. (#4824)
github-actions commentedon Jan 9, 2024
This issue seems stale. Please react to show this is still important.
wolflu05 commentedon Jan 9, 2024
Still wip in #4824, I now self assigned me this.