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

[IMP] base_report_to_printer: Paperformat #361

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions base_report_to_printer/models/printing_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
model = fields.Char(readonly=True)
location = fields.Char(readonly=True)
uri = fields.Char(string="URI", readonly=True)
paperformat_id = fields.Many2one("report.paperformat")
fit_to_page = fields.Boolean()
tray_ids = fields.One2many(
comodel_name="printing.tray", inverse_name="printer_id", string="Paper Sources"
)
Expand Down Expand Up @@ -170,6 +172,13 @@
options.update(getattr(self, "_set_option_%s" % option)(report, value))
except AttributeError:
options[option] = str(value)

if self.paperformat_id:
width = int(self.paperformat_id.print_page_width)
height = int(self.paperformat_id.print_page_height)
options["media"] = f"Custom.{width}x{height}mm"

Check warning on line 179 in base_report_to_printer/models/printing_printer.py

View check run for this annotation

Codecov / codecov/patch

base_report_to_printer/models/printing_printer.py#L177-L179

Added lines #L177 - L179 were not covered by tests
if self.fit_to_page:
options["fit-to-page"] = ""

Check warning on line 181 in base_report_to_printer/models/printing_printer.py

View check run for this annotation

Codecov / codecov/patch

base_report_to_printer/models/printing_printer.py#L181

Added line #L181 was not covered by tests
return options

def print_file(self, file_name, report=None, **print_opts):
Expand Down
4 changes: 4 additions & 0 deletions base_report_to_printer/views/printing_printer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
<field name="status" />
<field name="status_message" />
</group>
<group name="options">
<field name="paperformat_id" />
<field name="fit_to_page" />
</group>
<group string="Trays" name="trays">
<field name="tray_ids" nolabel="1">
<form>
Expand Down
Loading