Skip to content

Commit

Permalink
[FIX] base_report_to_printer: error printing in external network.
Browse files Browse the repository at this point in the history
Error code: 1030, 'The printer or class does not exist.')".
An explicit call to `setServer` and `setPort` fixed the issue.
(see OpenPrinting/pycups#30)

Also, added serve_id to printer views
  • Loading branch information
LoisRForgeFlow authored and trisdoan committed Oct 9, 2024
1 parent 8498062 commit bac98d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base_report_to_printer/models/printing_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def _open_connection(self, raise_on_error=False):
self.ensure_one()
connection = False
try:
# Sometimes connecting to printer servers outside of the local network
# can result in a weird error "cups.IPPError: (1030, 'The printer
# or class does not exist.')".
# An explicit call to `setServer` and `setPort` fixed the issue.
# (see https://github.com/OpenPrinting/pycups/issues/30)
cups.setServer(self.address)
cups.setPort(self.port)
connection = cups.Connection(host=self.address, port=self.port)
except Exception:
message = _(
Expand Down
2 changes: 2 additions & 0 deletions base_report_to_printer/views/printing_printer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
</div>
<group name="name">
<field name="system_name" />
<field name="server_id" />
</group>
<group col="4" colspan="4" name="default">
<field name="default" />
Expand Down Expand Up @@ -100,6 +101,7 @@
<field name="default" />
<field name="name" />
<field name="system_name" />
<field name="server_id" />
<field name="status" />
</tree>
</field>
Expand Down

0 comments on commit bac98d3

Please sign in to comment.