[IMP] base_report_to_printer: pre-commit auto fixes

This commit is contained in:
John Herholz
2024-03-08 10:08:59 +01:00
committed by trisdoan
parent 4f77ec14d4
commit 7b15d258e5
25 changed files with 929 additions and 674 deletions

View File

@@ -17,23 +17,26 @@ Report to printer
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freport--print--send-lightgray.png?logo=github
:target: https://github.com/OCA/report-print-send/tree/16.0/base_report_to_printer
:target: https://github.com/OCA/report-print-send/tree/17.0/base_report_to_printer
:alt: OCA/report-print-send
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/report-print-send-16-0/report-print-send-16-0-base_report_to_printer
:target: https://translation.odoo-community.org/projects/report-print-send-17-0/report-print-send-17-0-base_report_to_printer
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/report-print-send&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/report-print-send&target_branch=17.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module allows users to send reports to a printer attached to the server.
This module allows users to send reports to a printer attached to the
server.
It adds an optional behaviour on reports to send it directly to a printer.
It adds an optional behaviour on reports to send it directly to a
printer.
* `Send to Client` is the default behaviour providing you a downloadable PDF
* `Send to Printer` prints the report on selected printer
- Send to Client is the default behaviour providing you a downloadable
PDF
- Send to Printer prints the report on selected printer
It detects trays on printers installation plus permits to select the
paper source on which you want to print directly.
@@ -48,10 +51,10 @@ preprinted paper such as payment slip.
Settings can be configured:
* globally
* per user
* per report
* per user and report
- globally
- per user
- per report
- per user and report
**Table of contents**
@@ -63,9 +66,9 @@ Installation
To install this module, you need to:
#. Install PyCups - https://pypi.python.org/pypi/pycups
1. Install PyCups - https://pypi.python.org/pypi/pycups
.. code-block:: bash
.. code:: bash
sudo apt-get install cups
sudo apt-get install libcups2-dev
@@ -77,47 +80,49 @@ Configuration
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.
1. 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 "none" (or some other list of values which does not include
"job-name") , and reload the server. See `cupsd.conf(5)
<https://www.cups.org/doc/man-cupsd.conf.html>` for details.
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 "none" (or some other list of
values which does not include "job-name") , and reload the server. See
cupsd.conf(5) <https://www.cups.org/doc/man-cupsd.conf.html> for
details.
Usage
=====
Guidelines for use:
* To update the CUPS printers in *Settings > Printing > Update Printers
from CUPS*
* To print a report on a specific printer or tray, you can change
these in *Settings > Printing > Reports* to define default behaviour.
* To print a report on a specific printer and/or tray for a user, you can
change these in *Settings > Printing > Reports* in
- To update the CUPS printers in *Settings > Printing > Update
Printers from CUPS*
- To print a report on a specific printer or tray, you can change
these in *Settings > Printing > Reports* to define default
behaviour.
- To print a report on a specific printer and/or tray for a user,
you can change these in *Settings > Printing > Reports* in
*Specific actions per user*
* Users may also select a default action, printer or tray in their preferences.
- Users may also select a default action, printer or tray in their
preferences.
When no tray is configured for a report and a user, the
default tray setup on the CUPS server is used.
When no tray is configured for a report and a user, the default tray
setup on the CUPS server is used.
Changelog
=========
13.0.1.0.0 (2019-09-30)
~~~~~~~~~~~~~~~~~~~~~~~
-----------------------
* [RELEASE] Port from V12.
- [RELEASE] Port from V12.
12.0.1.0.0 (2018-02-04)
~~~~~~~~~~~~~~~~~~~~~~~
-----------------------
* [RELEASE] Port from V11.
- [RELEASE] Port from V11.
Bug Tracker
===========
@@ -125,7 +130,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/report-print-send/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/report-print-send/issues/new?body=module:%20base_report_to_printer%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/report-print-send/issues/new?body=module:%20base_report_to_printer%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -133,7 +138,7 @@ Credits
=======
Authors
~~~~~~~
-------
* Agile Business Group & Domsense
* Pegueroles SCP
@@ -143,28 +148,28 @@ Authors
* Open for Small Business Ltd
Contributors
~~~~~~~~~~~~
------------
* Ferran Pegueroles <ferran@pegueroles.com>
* Albert Cervera i Areny <albert@nan-tic.com>
* Davide Corio <davide.corio@agilebg.com>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
* Lionel Sausin <ls@numerigraphe.com>
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Dave Lasley <dave@laslabs.com>
* Sylvain Garancher <sylvain.garancher@syleam.fr>
* Jairo Llopis <jairo.llopis@tecnativa.com>
* Graeme Gellatly <graeme@o4sb.com>
* Rod Schouteden <rod@schout-it.be>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
* Matias Peralta <mnp@adhoc.com.ar>
* Hughes Damry <hughes.damry@acsone.eu>
* Akim Juillerat <akim.juillerat@camptocamp.com>
* Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
- Ferran Pegueroles <ferran@pegueroles.com>
- Albert Cervera i Areny <albert@nan-tic.com>
- Davide Corio <davide.corio@agilebg.com>
- Lorenzo Battistini <lorenzo.battistini@agilebg.com>
- Yannick Vaucher <yannick.vaucher@camptocamp.com>
- Lionel Sausin <ls@numerigraphe.com>
- Guewen Baconnier <guewen.baconnier@camptocamp.com>
- Dave Lasley <dave@laslabs.com>
- Sylvain Garancher <sylvain.garancher@syleam.fr>
- Jairo Llopis <jairo.llopis@tecnativa.com>
- Graeme Gellatly <graeme@o4sb.com>
- Rod Schouteden <rod@schout-it.be>
- Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
- Matias Peralta <mnp@adhoc.com.ar>
- Hughes Damry <hughes.damry@acsone.eu>
- Akim Juillerat <akim.juillerat@camptocamp.com>
- Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
Maintainers
~~~~~~~~~~~
-----------
This module is maintained by the OCA.
@@ -176,6 +181,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/report-print-send <https://github.com/OCA/report-print-send/tree/16.0/base_report_to_printer>`_ project on GitHub.
This module is part of the `OCA/report-print-send <https://github.com/OCA/report-print-send/tree/17.0/base_report_to_printer>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -183,17 +183,14 @@ class PrintingPrinter(models.Model):
options = self.print_options(report=report, **print_opts)
_logger.debug(
"Sending job to CUPS printer %s on %s with options %s"
% (self.system_name, self.server_id.address, options)
f"Sending job to CUPS printer {self.system_name} on {self.server_id.address} with options {options}"
)
connection.printFile(self.system_name, file_name, title, options=options)
_logger.info(
"Printing job: '{}' on {}".format(file_name, self.server_id.address)
)
_logger.info(f"Printing job: '{file_name}' on {self.server_id.address}")
try:
os.remove(file_name)
except OSError as exc:
_logger.warning("Unable to remove temporary file %s: %s", file_name, exc)
_logger.warning(f"Unable to remove temporary file {file_name}: {exc}")
return True
def set_default(self):

View File

@@ -8,7 +8,6 @@ from odoo import _, exceptions, fields, models
_logger = logging.getLogger(__name__)
try:
import cups
except ImportError:
@@ -87,6 +86,7 @@ class PrintingServer(models.Model):
def action_update_printers(self):
return self.update_printers(raise_on_error=True)
# ruff: noqa: B023
def update_printers(self, domain=None, raise_on_error=False):
if domain is None:
domain = []

View File

@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@@ -0,0 +1,13 @@
To configure this module, you need to:
1. 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 "none" (or some other list of
values which does not include "job-name") , and reload the server. See
cupsd.conf(5) \<https://www.cups.org/doc/man-cupsd.conf.html\> for
details.

View File

@@ -1,13 +0,0 @@
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 "none" (or some other list of values which does not include
"job-name") , and reload the server. See `cupsd.conf(5)
<https://www.cups.org/doc/man-cupsd.conf.html>` for details.

View File

@@ -0,0 +1,17 @@
- Ferran Pegueroles \<<ferran@pegueroles.com>\>
- Albert Cervera i Areny \<<albert@nan-tic.com>\>
- Davide Corio \<<davide.corio@agilebg.com>\>
- Lorenzo Battistini \<<lorenzo.battistini@agilebg.com>\>
- Yannick Vaucher \<<yannick.vaucher@camptocamp.com>\>
- Lionel Sausin \<<ls@numerigraphe.com>\>
- Guewen Baconnier \<<guewen.baconnier@camptocamp.com>\>
- Dave Lasley \<<dave@laslabs.com>\>
- Sylvain Garancher \<<sylvain.garancher@syleam.fr>\>
- Jairo Llopis \<<jairo.llopis@tecnativa.com>\>
- Graeme Gellatly \<<graeme@o4sb.com>\>
- Rod Schouteden \<<rod@schout-it.be>\>
- Alexandre Fayolle \<<alexandre.fayolle@camptocamp.com>\>
- Matias Peralta \<<mnp@adhoc.com.ar>\>
- Hughes Damry \<<hughes.damry@acsone.eu>\>
- Akim Juillerat \<<akim.juillerat@camptocamp.com>\>
- Jacques-Etienne Baudoux (BCIM) \<<je@bcim.be>\>

View File

@@ -1,17 +0,0 @@
* Ferran Pegueroles <ferran@pegueroles.com>
* Albert Cervera i Areny <albert@nan-tic.com>
* Davide Corio <davide.corio@agilebg.com>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
* Lionel Sausin <ls@numerigraphe.com>
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Dave Lasley <dave@laslabs.com>
* Sylvain Garancher <sylvain.garancher@syleam.fr>
* Jairo Llopis <jairo.llopis@tecnativa.com>
* Graeme Gellatly <graeme@o4sb.com>
* Rod Schouteden <rod@schout-it.be>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
* Matias Peralta <mnp@adhoc.com.ar>
* Hughes Damry <hughes.damry@acsone.eu>
* Akim Juillerat <akim.juillerat@camptocamp.com>
* Jacques-Etienne Baudoux (BCIM) <je@bcim.be>

View File

@@ -1,9 +1,12 @@
This module allows users to send reports to a printer attached to the server.
This module allows users to send reports to a printer attached to the
server.
It adds an optional behaviour on reports to send it directly to a printer.
It adds an optional behaviour on reports to send it directly to a
printer.
* `Send to Client` is the default behaviour providing you a downloadable PDF
* `Send to Printer` prints the report on selected printer
- Send to Client is the default behaviour providing you a downloadable
PDF
- Send to Printer prints the report on selected printer
It detects trays on printers installation plus permits to select the
paper source on which you want to print directly.
@@ -18,7 +21,7 @@ preprinted paper such as payment slip.
Settings can be configured:
* globally
* per user
* per report
* per user and report
- globally
- per user
- per report
- per user and report

View File

@@ -0,0 +1,7 @@
## 13.0.1.0.0 (2019-09-30)
- \[RELEASE\] Port from V12.
## 12.0.1.0.0 (2018-02-04)
- \[RELEASE\] Port from V11.

View File

@@ -1,9 +0,0 @@
13.0.1.0.0 (2019-09-30)
~~~~~~~~~~~~~~~~~~~~~~~
* [RELEASE] Port from V12.
12.0.1.0.0 (2018-02-04)
~~~~~~~~~~~~~~~~~~~~~~~
* [RELEASE] Port from V11.

View File

@@ -0,0 +1,10 @@
To install this module, you need to:
1. Install PyCups - <https://pypi.python.org/pypi/pycups>
``` bash
sudo apt-get install cups
sudo apt-get install libcups2-dev
sudo apt-get install python3-dev
sudo pip install pycups
```

View File

@@ -1,10 +0,0 @@
To install this module, you need to:
#. Install PyCups - https://pypi.python.org/pypi/pycups
.. code-block:: bash
sudo apt-get install cups
sudo apt-get install libcups2-dev
sudo apt-get install python3-dev
sudo pip install pycups

View File

@@ -0,0 +1,15 @@
Guidelines for use:
> - To update the CUPS printers in *Settings \> Printing \> Update
> Printers from CUPS*
> - To print a report on a specific printer or tray, you can change
> these in *Settings \> Printing \> Reports* to define default
> behaviour.
> - To print a report on a specific printer and/or tray for a user, you
> can change these in *Settings \> Printing \> Reports* in *Specific
> actions per user*
> - Users may also select a default action, printer or tray in their
> preferences.
When no tray is configured for a report and a user, the default tray
setup on the CUPS server is used.

View File

@@ -1,13 +0,0 @@
Guidelines for use:
* To update the CUPS printers in *Settings > Printing > Update Printers
from CUPS*
* To print a report on a specific printer or tray, you can change
these in *Settings > Printing > Reports* to define default behaviour.
* To print a report on a specific printer and/or tray for a user, you can
change these in *Settings > Printing > Reports* in
*Specific actions per user*
* Users may also select a default action, printer or tray in their preferences.
When no tray is configured for a report and a user, the
default tray setup on the CUPS server is used.

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ model = "odoo.addons.base.models.ir_actions_report.IrActionsReport"
class TestIrActionsReportXml(TransactionCase):
def setUp(self):
super(TestIrActionsReportXml, self).setUp()
super().setUp()
self.Model = self.env["ir.actions.report"]
self.vals = {}
@@ -77,7 +77,7 @@ class TestIrActionsReportXml(TransactionCase):
"action": behaviour["action"],
"printer_name": behaviour["printer"].name,
}
self.assertDictEqual(expect, res, "Expect {}, Got {}".format(expect, res))
self.assertDictEqual(expect, res, f"Expect {expect}, Got {res}")
def test_behaviour_default_values(self):
"""It should return the default action and printer"""

View File

@@ -11,7 +11,7 @@ model = "odoo.addons.base_report_to_printer.models.printing_server"
class TestPrintingJob(TransactionCase):
def setUp(self):
super(TestPrintingJob, self).setUp()
super().setUp()
self.Model = self.env["printing.server"]
self.server = self.Model.create({})
self.printer_vals = {

View File

@@ -13,7 +13,7 @@ server_model = "odoo.addons.base_report_to_printer.models.printing_server"
class TestPrintingPrinter(TransactionCase):
def setUp(self):
super(TestPrintingPrinter, self).setUp()
super().setUp()
self.Model = self.env["printing.printer"]
self.ServerModel = self.env["printing.server"]
self.server = self.env["printing.server"].create({})

View File

@@ -34,7 +34,7 @@ ppd_input_slot_footer = """
class TestPrintingPrinter(TransactionCase):
def setUp(self):
super(TestPrintingPrinter, self).setUp()
super().setUp()
self.Model = self.env["printing.printer"]
self.ServerModel = self.env["printing.server"]
self.server = self.env["printing.server"].create({})

View File

@@ -6,7 +6,7 @@ from odoo.tests.common import TransactionCase
class TestPrintingReportXmlAction(TransactionCase):
def setUp(self):
super(TestPrintingReportXmlAction, self).setUp()
super().setUp()
self.Model = self.env["printing.report.xml.action"]
self.report = self.env["ir.actions.report"].search([], limit=1)

View File

@@ -12,7 +12,7 @@ model_base = "odoo.models.BaseModel"
class TestPrintingServer(TransactionCase):
def setUp(self):
super(TestPrintingServer, self).setUp()
super().setUp()
self.Model = self.env["printing.server"]
self.server = self.Model.create({})
self.printer_vals = {

View File

@@ -8,7 +8,7 @@ model = "odoo.addons.base_report_to_printer.models.printing_server"
class TestPrintingTray(TransactionCase):
def setUp(self):
super(TestPrintingTray, self).setUp()
super().setUp()
self.Model = self.env["printing.tray"]
self.server = self.env["printing.server"].create({})
self.printer = self.env["printing.printer"].create(

View File

@@ -10,7 +10,7 @@ from odoo.tests import common
class TestReport(common.HttpCase):
def setUp(self):
super(TestReport, self).setUp()
super().setUp()
self.Model = self.env["ir.actions.report"]
self.server = self.env["printing.server"].create({})
self.report_vals = {

View File

@@ -6,7 +6,7 @@ from odoo.tests import common
class TestResUsers(common.TransactionCase):
def setUp(self):
super(TestResUsers, self).setUp()
super().setUp()
self.user_vals = {"name": "Test", "login": "login"}
def new_record(self):