Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add printing options framework #31

Merged
merged 3 commits into from
Nov 3, 2023
Merged

Add printing options framework #31

merged 3 commits into from
Nov 3, 2023

Conversation

SchrodingersGat
Copy link
Member

For now, this only adds in a "number of copies" option. But, other options could be added too. For example if multiple printers are available on the network, select which one to use

@Alex9779
Copy link

Alex9779 commented Nov 1, 2023

Ok you are freakin awsome :P
From my point of view not all paramters need to be added, I have just one printer and I don't think I will need more soon, but if you also allow changing the printer then I think all will be needed...

@SchrodingersGat
Copy link
Member Author

@wolflu05 has done most of the heavy lifting here (and this won't work until the linked PR is merged into InvenTree master)

Copy link

@wolflu05 wolflu05 left a comment

Choose a reason for hiding this comment

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

Implementation LGTM. But overall this would mean every plugin needs to implement such options.

# Printing options requires a modern-ish InvenTree backend,
# which supports the 'printing_options' keyword argument
options = kwargs.get('printing_options', {})
n_copies = min(1, options.get('copies', 1))
Copy link

Choose a reason for hiding this comment

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

Why this min function? Doesn't that mean if I set copies to 10, I still get 1? I think the min/max could be generally left out, because you already set the default at the .get function.

@@ -57,6 +80,8 @@ class BrotherLabelPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlugin):
SLUG = "brother"
TITLE = "Brother Label Printer"

PrintingOptionsSerializer = BrotherLabelSerializer
Copy link

Choose a reason for hiding this comment

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

Comment: Yep, that's another way of defining the options I haven't thought of, but Program wise they are exactly considered the same.

Used to specify printing parameters at runtime
"""

class Meta:
Copy link

@wolflu05 wolflu05 Nov 1, 2023

Choose a reason for hiding this comment

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

Comment: the serializer also worked without a meta class in my tests, I guess it is only necessary for model serializers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I saw your example now, I might simplify it

@SchrodingersGat SchrodingersGat merged commit 6397c4b into main Nov 3, 2023
2 checks passed
@SchrodingersGat SchrodingersGat deleted the print-copies branch November 3, 2023 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants