From 2f8495e27395a6aab5a0c9a76e748ee6450e4f16 Mon Sep 17 00:00:00 2001
From: trisdoan
Date: Mon, 14 Oct 2024 11:10:05 +0700
Subject: [PATCH] [MIG] base_report_to_printer: Migration to 18.0
[MIG] base_report_to_printer: Migration to 18.0
---
base_report_to_printer/README.rst | 17 +++++++----
base_report_to_printer/__manifest__.py | 2 +-
base_report_to_printer/data/printing_data.xml | 16 ++++-------
.../models/ir_actions_report.py | 2 +-
.../models/printing_action.py | 18 ++++++------
.../models/printing_printer.py | 2 +-
.../models/printing_report_xml_action.py | 2 +-
base_report_to_printer/models/res_users.py | 14 ++++------
base_report_to_printer/readme/CONTRIBUTORS.md | 1 +
base_report_to_printer/readme/CREDITS.md | 1 +
.../static/description/index.html | 28 +++++++++++++------
.../static/src/js/qweb_action_manager.esm.js | 1 -
.../tests/test_ir_actions_report.py | 6 ++--
.../tests/test_printing_job.py | 4 +--
.../tests/test_printing_printer.py | 22 +++++++--------
.../tests/test_printing_printer_tray.py | 18 ++++++------
.../tests/test_printing_printer_wizard.py | 10 +++----
.../tests/test_printing_server.py | 28 +++++++++----------
base_report_to_printer/views/printing_job.xml | 4 +--
.../views/printing_printer.xml | 6 ++--
.../views/printing_report.xml | 4 +--
.../views/printing_server.xml | 6 ++--
.../wizards/print_attachment_report.xml | 4 +--
.../wizards/printing_printer_update_wizard.py | 2 +-
24 files changed, 113 insertions(+), 105 deletions(-)
create mode 100644 base_report_to_printer/readme/CREDITS.md
diff --git a/base_report_to_printer/README.rst b/base_report_to_printer/README.rst
index 009291b738b..2407e9322f3 100644
--- a/base_report_to_printer/README.rst
+++ b/base_report_to_printer/README.rst
@@ -17,13 +17,13 @@ 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/17.0/base_report_to_printer
+ :target: https://github.com/OCA/report-print-send/tree/18.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-17-0/report-print-send-17-0-base_report_to_printer
+ :target: https://translation.odoo-community.org/projects/report-print-send-18-0/report-print-send-18-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=17.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/report-print-send&target_branch=18.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -131,7 +131,7 @@ Bug Tracker
Bugs are tracked on `GitHub 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -168,6 +168,13 @@ Contributors
- Hughes Damry
- Akim Juillerat
- Jacques-Etienne Baudoux (BCIM)
+- Tris Doan
+
+Other credits
+-------------
+
+The migration of this module from 17.0 to 18.0 was financially supported
+by Camptocamp.
Maintainers
-----------
@@ -182,6 +189,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 `_ project on GitHub.
+This module is part of the `OCA/report-print-send `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/base_report_to_printer/__manifest__.py b/base_report_to_printer/__manifest__.py
index 21051614345..6a27e25dd85 100644
--- a/base_report_to_printer/__manifest__.py
+++ b/base_report_to_printer/__manifest__.py
@@ -7,7 +7,7 @@
{
"name": "Report to printer",
- "version": "17.0.1.0.1",
+ "version": "18.0.1.0.0",
"category": "Generic Modules/Base",
"author": "Agile Business Group & Domsense, Pegueroles SCP, NaN,"
" LasLabs, Camptocamp, Odoo Community Association (OCA),"
diff --git a/base_report_to_printer/data/printing_data.xml b/base_report_to_printer/data/printing_data.xml
index c008aa5214a..f9304756ec0 100644
--- a/base_report_to_printer/data/printing_data.xml
+++ b/base_report_to_printer/data/printing_data.xml
@@ -9,25 +9,19 @@
Send to Client
client
-
-
- property_printing_action_id
-
-
-
Update Printers Jobs
1
minutes
- -1
-
code
model.action_update_jobs()
+
diff --git a/base_report_to_printer/models/ir_actions_report.py b/base_report_to_printer/models/ir_actions_report.py
index b7d05a55fd8..2f424bb1626 100644
--- a/base_report_to_printer/models/ir_actions_report.py
+++ b/base_report_to_printer/models/ir_actions_report.py
@@ -108,7 +108,7 @@ def print_document(self, record_ids, data=None):
_("This report type (%s) is not supported by direct printing!")
% str(self.report_type)
)
- method_name = "_render_qweb_%s" % (report_type)
+ method_name = f"_render_qweb_{report_type}"
document, doc_format = getattr(
self.with_context(must_skip_send_to_printer=True), method_name
)(self.report_name, record_ids, data=data)
diff --git a/base_report_to_printer/models/printing_action.py b/base_report_to_printer/models/printing_action.py
index aa180802a22..de5c070eacb 100644
--- a/base_report_to_printer/models/printing_action.py
+++ b/base_report_to_printer/models/printing_action.py
@@ -5,22 +5,22 @@
# Copyright (C) 2013-2014 Camptocamp ()
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, fields, models
+from odoo import fields, models
+
+AVAILABLE_ACTION_TYPES = [
+ ("server", "Send to Printer"),
+ ("client", "Send to Client"),
+ ("user_default", "Use user's defaults"),
+]
class PrintingAction(models.Model):
_name = "printing.action"
_description = "Print Job Action"
- @api.model
- def _available_action_types(self):
- return [
- ("server", "Send to Printer"),
- ("client", "Send to Client"),
- ("user_default", "Use user's defaults"),
- ]
+ _available_action_types = AVAILABLE_ACTION_TYPES
name = fields.Char(required=True)
action_type = fields.Selection(
- selection=_available_action_types, string="Type", required=True
+ selection=AVAILABLE_ACTION_TYPES, string="Type", required=True
)
diff --git a/base_report_to_printer/models/printing_printer.py b/base_report_to_printer/models/printing_printer.py
index 8d2811ef29f..ac44319b76e 100644
--- a/base_report_to_printer/models/printing_printer.py
+++ b/base_report_to_printer/models/printing_printer.py
@@ -170,7 +170,7 @@ def print_options(self, report=None, **print_opts):
options = {}
for option, value in print_opts.items():
try:
- options.update(getattr(self, "_set_option_%s" % option)(report, value))
+ options.update(getattr(self, f"_set_option_{option}")(report, value))
except AttributeError:
options[option] = str(value)
return options
diff --git a/base_report_to_printer/models/printing_report_xml_action.py b/base_report_to_printer/models/printing_report_xml_action.py
index cac2a0b39b7..06d7a965ffe 100644
--- a/base_report_to_printer/models/printing_report_xml_action.py
+++ b/base_report_to_printer/models/printing_report_xml_action.py
@@ -22,7 +22,7 @@ class PrintingReportXmlAction(models.Model):
comodel_name="res.users", string="User", required=True, ondelete="cascade"
)
action = fields.Selection(
- selection=lambda s: s.env["printing.action"]._available_action_types(),
+ selection=lambda s: s.env["printing.action"]._available_action_types,
required=True,
)
printer_id = fields.Many2one(comodel_name="printing.printer", string="Printer")
diff --git a/base_report_to_printer/models/res_users.py b/base_report_to_printer/models/res_users.py
index cb088ed0d1f..ff24e4e8acc 100644
--- a/base_report_to_printer/models/res_users.py
+++ b/base_report_to_printer/models/res_users.py
@@ -7,19 +7,15 @@
from odoo import api, fields, models
+from .printing_action import AVAILABLE_ACTION_TYPES
+
+action_types = [type for type in AVAILABLE_ACTION_TYPES if type[0] != "user_default"]
+
class ResUsers(models.Model):
_inherit = "res.users"
- @api.model
- def _user_available_action_types(self):
- return [
- (code, string)
- for code, string in self.env["printing.action"]._available_action_types()
- if code != "user_default"
- ]
-
- printing_action = fields.Selection(selection=_user_available_action_types)
+ printing_action = fields.Selection(selection=action_types)
printing_printer_id = fields.Many2one(
comodel_name="printing.printer", string="Default Printer"
)
diff --git a/base_report_to_printer/readme/CONTRIBUTORS.md b/base_report_to_printer/readme/CONTRIBUTORS.md
index 2e89c72169c..84cef65de94 100644
--- a/base_report_to_printer/readme/CONTRIBUTORS.md
+++ b/base_report_to_printer/readme/CONTRIBUTORS.md
@@ -15,3 +15,4 @@
- Hughes Damry \<\>
- Akim Juillerat \<\>
- Jacques-Etienne Baudoux (BCIM) \<\>
+- Tris Doan \<\>
diff --git a/base_report_to_printer/readme/CREDITS.md b/base_report_to_printer/readme/CREDITS.md
new file mode 100644
index 00000000000..83b3ec91f7d
--- /dev/null
+++ b/base_report_to_printer/readme/CREDITS.md
@@ -0,0 +1 @@
+The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp.
diff --git a/base_report_to_printer/static/description/index.html b/base_report_to_printer/static/description/index.html
index 6aec188be7c..b38ad34cd59 100644
--- a/base_report_to_printer/static/description/index.html
+++ b/base_report_to_printer/static/description/index.html
@@ -8,10 +8,11 @@
/*
:Author: David Goodger (goodger@python.org)
-:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
+:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
+Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }
-pre.code .ln { color: grey; } /* line numbers */
+pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@
span.pre {
white-space: pre }
-span.problematic {
+span.problematic, pre.problematic {
color: red }
span.section-subtitle {
@@ -368,7 +369,7 @@ Report to printer
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3d37f5e02c22560d293e60d6fb565eea3a6657926defd87d4a6ca71cc229ab60
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
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
@@ -407,7 +408,8 @@
Report to printer
Credits
@@ -482,7 +484,7 @@
Bugs are tracked on GitHub 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 .
+feedback .
Do not contact contributors directly about support or help with technical issues.
+
+
+
The migration of this module from 17.0 to 18.0 was financially supported
+by Camptocamp.
+
-
+
This module is maintained by the OCA.
-
+
+
+
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 project on GitHub.
+
This module is part of the OCA/report-print-send project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute .
diff --git a/base_report_to_printer/static/src/js/qweb_action_manager.esm.js b/base_report_to_printer/static/src/js/qweb_action_manager.esm.js
index d9f9769f566..d54718ceb19 100644
--- a/base_report_to_printer/static/src/js/qweb_action_manager.esm.js
+++ b/base_report_to_printer/static/src/js/qweb_action_manager.esm.js
@@ -1,4 +1,3 @@
-/** @odoo-module */
import {_t} from "@web/core/l10n/translation";
import {registry} from "@web/core/registry";
diff --git a/base_report_to_printer/tests/test_ir_actions_report.py b/base_report_to_printer/tests/test_ir_actions_report.py
index 0ba5a873abc..f4e3ea70f59 100644
--- a/base_report_to_printer/tests/test_ir_actions_report.py
+++ b/base_report_to_printer/tests/test_ir_actions_report.py
@@ -55,14 +55,14 @@ def new_tray(self, vals=None, defaults=None):
def test_print_action_for_report_name_gets_report(self):
"""It should get report by name"""
- with mock.patch("%s._get_report_from_name" % model) as mk:
+ with mock.patch(f"{model}._get_report_from_name") as mk:
expect = "test"
self.Model.print_action_for_report_name(expect)
mk.assert_called_once_with(expect)
def test_print_action_for_report_name_returns_if_no_report(self):
"""It should return empty dict when no matching report"""
- with mock.patch("%s._get_report_from_name" % model) as mk:
+ with mock.patch(f"{model}._get_report_from_name") as mk:
expect = "test"
mk.return_value = False
res = self.Model.print_action_for_report_name(expect)
@@ -70,7 +70,7 @@ def test_print_action_for_report_name_returns_if_no_report(self):
def test_print_action_for_report_name_returns_if_report(self):
"""It should return correct serializable result for behaviour"""
- with mock.patch("%s._get_report_from_name" % model) as mk:
+ with mock.patch(f"{model}._get_report_from_name") as mk:
res = self.Model.print_action_for_report_name("test")
behaviour = mk().behaviour()
expect = {
diff --git a/base_report_to_printer/tests/test_printing_job.py b/base_report_to_printer/tests/test_printing_job.py
index dd02a1011ba..2e2a69d24f0 100644
--- a/base_report_to_printer/tests/test_printing_job.py
+++ b/base_report_to_printer/tests/test_printing_job.py
@@ -42,7 +42,7 @@ def new_job(self, printer, vals=None):
values["printer_id"] = printer.id
return self.env["printing.job"].create(values)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_cancel_job_error(self, cups):
"""It should catch any exception from CUPS and update status"""
cups.Connection.side_effect = Exception
@@ -52,7 +52,7 @@ def test_cancel_job_error(self, cups):
cups.Connection.side_effect = None
self.assertEqual(cups.Connection().cancelJob.call_count, 0)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_cancel_job(self, cups):
"""It should catch any exception from CUPS and update status"""
printer = self.new_printer()
diff --git a/base_report_to_printer/tests/test_printing_printer.py b/base_report_to_printer/tests/test_printing_printer.py
index 8ea7d83c3a1..62453d5a335 100644
--- a/base_report_to_printer/tests/test_printing_printer.py
+++ b/base_report_to_printer/tests/test_printing_printer.py
@@ -79,11 +79,11 @@ def test_print_options(self):
)
self.assertTrue("InputSlot" in self.Model.print_options(report, tray="Test"))
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_print_report(self, cups):
"""It should print a report through CUPS"""
fd, file_name = tempfile.mkstemp()
- with mock.patch("%s.mkstemp" % model) as mkstemp:
+ with mock.patch(f"{model}.mkstemp") as mkstemp:
mkstemp.return_value = fd, file_name
printer = self.new_record()
printer.print_document(self.report, b"content to print", doc_format="pdf")
@@ -91,12 +91,12 @@ def test_print_report(self, cups):
printer.system_name, file_name, file_name, options={}
)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_print_report_error(self, cups):
"""It should print a report through CUPS"""
cups.Connection.side_effect = Exception
fd, file_name = tempfile.mkstemp()
- with mock.patch("%s.mkstemp" % model) as mkstemp:
+ with mock.patch(f"{model}.mkstemp") as mkstemp:
mkstemp.return_value = fd, file_name
printer = self.new_record()
with self.assertRaises(UserError):
@@ -104,7 +104,7 @@ def test_print_report_error(self, cups):
self.report, b"content to print", doc_format="pdf"
)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_print_file(self, cups):
"""It should print a file through CUPS"""
file_name = "file_name"
@@ -114,7 +114,7 @@ def test_print_file(self, cups):
printer.system_name, file_name, file_name, options={}
)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_print_file_error(self, cups):
"""It should print a file through CUPS"""
cups.Connection.side_effect = Exception
@@ -142,7 +142,7 @@ def test_unset_default(self):
printer.unset_default()
self.assertFalse(printer.default)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_cancel_all_jobs(self, cups):
"""It should cancel all jobs"""
printer = self.new_record()
@@ -151,7 +151,7 @@ def test_cancel_all_jobs(self, cups):
name=printer.system_name, purge_jobs=False
)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_cancel_and_purge_all_jobs(self, cups):
"""It should cancel all jobs"""
printer = self.new_record()
@@ -160,21 +160,21 @@ def test_cancel_and_purge_all_jobs(self, cups):
name=printer.system_name, purge_jobs=True
)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_enable_printer(self, cups):
"""It should enable the printer"""
printer = self.new_record()
printer.enable()
cups.Connection().enablePrinter.assert_called_once_with(printer.system_name)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_disable_printer(self, cups):
"""It should disable the printer"""
printer = self.new_record()
printer.disable()
cups.Connection().disablePrinter.assert_called_once_with(printer.system_name)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_print_test_page(self, cups):
"""It should print a test page"""
printer = self.new_record()
diff --git a/base_report_to_printer/tests/test_printing_printer_tray.py b/base_report_to_printer/tests/test_printing_printer_tray.py
index 158864330b8..cc6d958b47e 100644
--- a/base_report_to_printer/tests/test_printing_printer_tray.py
+++ b/base_report_to_printer/tests/test_printing_printer_tray.py
@@ -99,7 +99,7 @@ def mock_cups_ppd(self, cups, file_name=None, input_slots=None):
}
}
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_update_printers(self, cups):
"""
Check that the update_printers method calls _prepare_update_from_cups
@@ -110,7 +110,7 @@ def test_update_printers(self, cups):
self.ServerModel.update_printers()
self.assertEqual(self.printer.name, "info")
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_prepare_update_from_cups_no_ppd(self, cups):
"""
Check that the tray_ids field has no value when no PPD is available
@@ -123,7 +123,7 @@ def test_prepare_update_from_cups_no_ppd(self, cups):
vals = self.printer._prepare_update_from_cups(connection, cups_printer)
self.assertFalse("tray_ids" in vals)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_prepare_update_from_cups_empty_ppd(self, cups):
"""
Check that the tray_ids field has no value when the PPD file has
@@ -141,7 +141,7 @@ def test_prepare_update_from_cups_empty_ppd(self, cups):
vals = self.printer._prepare_update_from_cups(connection, cups_printer)
self.assertFalse("tray_ids" in vals)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
@mock.patch("os.unlink")
def test_prepare_update_from_cups_unlink_error(self, os_unlink, cups):
"""
@@ -158,7 +158,7 @@ def test_prepare_update_from_cups_unlink_error(self, os_unlink, cups):
with self.assertRaises(OSError):
self.printer._prepare_update_from_cups(connection, cups_printer)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
@mock.patch("os.unlink")
def test_prepare_update_from_cups_unlink_error_enoent(self, os_unlink, cups):
"""
@@ -180,7 +180,7 @@ def test_prepare_update_from_cups_unlink_error_enoent(self, os_unlink, cups):
[(0, 0, {"name": "Auto (Default)", "system_name": "Auto"})],
)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_prepare_update_from_cups(self, cups):
"""
Check the return value when adding a single tray
@@ -196,7 +196,7 @@ def test_prepare_update_from_cups(self, cups):
[(0, 0, {"name": "Auto (Default)", "system_name": "Auto"})],
)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_prepare_update_from_cups_with_multiple_trays(self, cups):
"""
Check the return value when adding multiple trays at once
@@ -215,7 +215,7 @@ def test_prepare_update_from_cups_with_multiple_trays(self, cups):
],
)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_prepare_update_from_cups_already_known_trays(self, cups):
"""
Check that calling the method twice doesn't create the trays multiple
@@ -235,7 +235,7 @@ def test_prepare_update_from_cups_already_known_trays(self, cups):
[(0, 0, {"name": "Auto (Default)", "system_name": "Auto"})],
)
- @mock.patch("%s.cups" % server_model)
+ @mock.patch(f"{server_model}.cups")
def test_prepare_update_from_cups_unknown_trays(self, cups):
"""
Check that trays which are not in the PPD file are removed from Odoo
diff --git a/base_report_to_printer/tests/test_printing_printer_wizard.py b/base_report_to_printer/tests/test_printing_printer_wizard.py
index 11788c01e2e..7a4190b6d38 100644
--- a/base_report_to_printer/tests/test_printing_printer_wizard.py
+++ b/base_report_to_printer/tests/test_printing_printer_wizard.py
@@ -36,7 +36,7 @@ def _record_vals(self, sys_name="sys_name"):
"uri": self.printer_vals["device-uri"],
}
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_action_ok_inits_connection(self, cups):
"""It should initialize CUPS connection"""
self.Model.action_ok()
@@ -44,7 +44,7 @@ def test_action_ok_inits_connection(self, cups):
host=self.server.address, port=self.server.port
)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_action_ok_gets_printers(self, cups):
"""It should get printers from CUPS"""
cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals}
@@ -52,14 +52,14 @@ def test_action_ok_gets_printers(self, cups):
self.Model.action_ok()
cups.Connection().getPrinters.assert_called_once_with()
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_action_ok_raises_warning_on_error(self, cups):
"""It should raise Warning on any error"""
cups.Connection.side_effect = StopTest
with self.assertRaises(UserError):
self.Model.action_ok()
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_action_ok_creates_new_printer(self, cups):
"""It should create new printer w/ proper vals"""
cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals}
@@ -75,7 +75,7 @@ def test_action_ok_creates_new_printer(self, cups):
self.assertEqual(val, rec_id[key])
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_action_ok_skips_existing_printer(self, cups):
"""It should not recreate existing printers"""
cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals}
diff --git a/base_report_to_printer/tests/test_printing_server.py b/base_report_to_printer/tests/test_printing_server.py
index 9fb2151ffab..3b359f8781e 100644
--- a/base_report_to_printer/tests/test_printing_server.py
+++ b/base_report_to_printer/tests/test_printing_server.py
@@ -43,7 +43,7 @@ def new_job(self, printer, vals=None):
values["printer_id"] = printer.id
return self.env["printing.job"].create(values)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_printers_error(self, cups):
"""It should catch any exception from CUPS and update status"""
cups.Connection.side_effect = Exception
@@ -51,7 +51,7 @@ def test_update_printers_error(self, cups):
self.Model.update_printers()
self.assertEqual("server-error", rec_id.status)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_printers_inits_cups(self, cups):
"""It should init CUPS connection"""
self.new_printer()
@@ -60,29 +60,29 @@ def test_update_printers_inits_cups(self, cups):
host=self.server.address, port=self.server.port
)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_printers_gets_all_printers(self, cups):
"""It should get all printers from CUPS server"""
self.new_printer()
self.Model.update_printers()
cups.Connection().getPrinters.assert_called_once_with()
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_printers_search(self, cups):
"""It should search all when no domain"""
- with mock.patch("%s.search" % model_base) as search:
+ with mock.patch(f"{model_base}.search") as search:
self.Model.update_printers()
search.assert_called_once_with([])
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_printers_search_domain(self, cups):
"""It should use specific domain for search"""
- with mock.patch("%s.search" % model_base) as search:
+ with mock.patch(f"{model_base}.search") as search:
expect = [("id", ">", 0)]
self.Model.update_printers(expect)
search.assert_called_once_with(expect)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_printers_update_unavailable(self, cups):
"""It should update status when printer is unavailable"""
rec_id = self.new_printer()
@@ -90,7 +90,7 @@ def test_update_printers_update_unavailable(self, cups):
self.Model.action_update_printers()
self.assertEqual("unavailable", rec_id.status)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_archived_printers(self, cups):
"""It should update status even if printer is archived"""
rec_id = self.new_printer()
@@ -103,7 +103,7 @@ def test_update_archived_printers(self, cups):
rec_id.status,
)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_jobs_cron(self, cups):
"""It should get all jobs from CUPS server"""
self.new_printer()
@@ -125,7 +125,7 @@ def test_update_jobs_cron(self, cups):
],
)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_jobs_button(self, cups):
"""It should get all jobs from CUPS server"""
self.new_printer()
@@ -147,7 +147,7 @@ def test_update_jobs_button(self, cups):
],
)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_jobs_error(self, cups):
"""It should catch any exception from CUPS and update status"""
cups.Connection.side_effect = Exception
@@ -157,7 +157,7 @@ def test_update_jobs_error(self, cups):
host=self.server.address, port=self.server.port
)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_jobs_uncompleted(self, cups):
"""
It should search which jobs have been completed since last update
@@ -182,7 +182,7 @@ def test_update_jobs_uncompleted(self, cups):
],
)
- @mock.patch("%s.cups" % model)
+ @mock.patch(f"{model}.cups")
def test_update_jobs(self, cups):
"""
It should update all jobs, known or not
diff --git a/base_report_to_printer/views/printing_job.xml b/base_report_to_printer/views/printing_job.xml
index 1fd513f5cc4..48647031b04 100644
--- a/base_report_to_printer/views/printing_job.xml
+++ b/base_report_to_printer/views/printing_job.xml
@@ -36,11 +36,11 @@
printing.job.tree (in base_report_to_printer)
printing.job
-
+
-
+
diff --git a/base_report_to_printer/views/printing_printer.xml b/base_report_to_printer/views/printing_printer.xml
index 4424c84b13d..47c559e6aa1 100644
--- a/base_report_to_printer/views/printing_printer.xml
+++ b/base_report_to_printer/views/printing_printer.xml
@@ -100,7 +100,7 @@
printing.printer.tree (in base_report_to_printer)
printing.printer
-
-
+
@@ -134,7 +134,7 @@
Show Printers
ir.actions.act_window
printing.printer
- tree,form
+ list,form
printing.report.xml.action.tree (in base_report_to_printer)
printing.report.xml.action
-
+
-
+
diff --git a/base_report_to_printer/views/printing_server.xml b/base_report_to_printer/views/printing_server.xml
index de9a04be2bf..d4397399ecd 100644
--- a/base_report_to_printer/views/printing_server.xml
+++ b/base_report_to_printer/views/printing_server.xml
@@ -44,11 +44,11 @@
printing.server.tree (in base_report_to_printer)
printing.server
-
+
-
+
@@ -66,7 +66,7 @@
Servers
ir.actions.act_window
printing.server
- tree,form
+ list,form
-
+
-
+
diff --git a/base_report_to_printer/wizards/printing_printer_update_wizard.py b/base_report_to_printer/wizards/printing_printer_update_wizard.py
index 8f716e845a3..e9a57b5fb36 100644
--- a/base_report_to_printer/wizards/printing_printer_update_wizard.py
+++ b/base_report_to_printer/wizards/printing_printer_update_wizard.py
@@ -20,7 +20,7 @@ def action_ok(self):
return {
"name": "Printers",
- "view_mode": "tree,form",
+ "view_mode": "list,form",
"res_model": "printing.printer",
"type": "ir.actions.act_window",
"target": "current",