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 flachica committed Oct 1, 2022
1 parent 6c3c7f3 commit 7af32a7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions base_report_to_printer/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ To configure this module, you need to:
#. Enable the "Printing / Print User" option under access
rights to give users the ability to view the print menu.


The jobs will be sent to the printer with a name matching the print_report_name
of the report (truncated at 80 characters). By default this will not be
displayed by CUPS web interface or in Odoo. To see this information, you need
to change the configuration of your CUPS server and set the JobPrivateValue
directive to "job-name", and reload the server. See `cupsd.conf(5)
<https://www.cups.org/doc/man-cupsd.conf.html>` for details.

Usage
=====

Expand Down Expand Up @@ -145,6 +153,7 @@ Contributors
* Jairo Llopis <[email protected]>
* Graeme Gellatly <[email protected]>
* Rod Schouteden <[email protected]>
* Alexandre Fayolle <[email protected]>

Maintainers
~~~~~~~~~~~
Expand Down
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
7 changes: 7 additions & 0 deletions base_report_to_printer/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ <h1><a class="toc-backref" href="#id4">Configuration</a></h1>
<li>Enable the “Printing / Print User” option under access
rights to give users the ability to view the print menu.</li>
</ol>
<p>The jobs will be sent to the printer with a name matching the print_report_name
of the report (truncated at 80 characters). By default this will not be
displayed by CUPS web interface or in Odoo. To see this information, you need
to change the configuration of your CUPS server and set the JobPrivateValue
directive to “job-name”, and reload the server. See <cite>cupsd.conf(5)
&lt;https://www.cups.org/doc/man-cupsd.conf.html&gt;</cite> for details.</p>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id5">Usage</a></h1>
Expand Down Expand Up @@ -498,6 +504,7 @@ <h2><a class="toc-backref" href="#id12">Contributors</a></h2>
<li>Jairo Llopis &lt;<a class="reference external" href="mailto:jairo.llopis&#64;tecnativa.com">jairo.llopis&#64;tecnativa.com</a>&gt;</li>
<li>Graeme Gellatly &lt;<a class="reference external" href="mailto:graeme&#64;o4sb.com">graeme&#64;o4sb.com</a>&gt;</li>
<li>Rod Schouteden &lt;<a class="reference external" href="mailto:rod&#64;schout-it.be">rod&#64;schout-it.be</a>&gt;</li>
<li>Alexandre Fayolle &lt;<a class="reference external" href="mailto:alexandre.fayolle&#64;camptocamp.com">alexandre.fayolle&#64;camptocamp.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
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 7af32a7

Please sign in to comment.