[FIX] base_report_to_printer: error printing in external network.

Error code: 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)

Also, added serve_id to printer views
This commit is contained in:
Lois Rilo
2021-11-16 15:59:25 +01:00
committed by trisdoan
parent 2aa2979416
commit f00a4677ad
2 changed files with 9 additions and 0 deletions

View File

@@ -36,6 +36,13 @@ class PrintingServer(models.Model):
self.ensure_one() self.ensure_one()
connection = False connection = False
try: 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) connection = cups.Connection(host=self.address, port=self.port)
except Exception: except Exception:
message = _( message = _(

View File

@@ -47,6 +47,7 @@
</div> </div>
<group name="name"> <group name="name">
<field name="system_name" /> <field name="system_name" />
<field name="server_id" />
</group> </group>
<group col="4" colspan="4" name="default"> <group col="4" colspan="4" name="default">
<field name="default" /> <field name="default" />
@@ -100,6 +101,7 @@
<field name="default" /> <field name="default" />
<field name="name" /> <field name="name" />
<field name="system_name" /> <field name="system_name" />
<field name="server_id" />
<field name="status" /> <field name="status" />
</tree> </tree>
</field> </field>