From 5e29d497d507014dcb9293826331f4fa45707807 Mon Sep 17 00:00:00 2001 From: Carlos Roca Date: Tue, 12 Jan 2021 09:33:27 +0100 Subject: [PATCH] [IMP] base_report_to_printer: black, isort, prettier --- base_report_to_printer/models/ir_actions_report.py | 4 ++-- base_report_to_printer/models/printing_printer.py | 2 +- .../static/src/js/qweb_action_manager.js | 10 +++++----- .../tests/test_ir_actions_report.py | 14 ++++++-------- .../tests/test_printing_report_xml_action.py | 4 ++-- .../tests/test_printing_server.py | 3 ++- base_report_to_printer/tests/test_report.py | 6 ++---- 7 files changed, 20 insertions(+), 23 deletions(-) diff --git a/base_report_to_printer/models/ir_actions_report.py b/base_report_to_printer/models/ir_actions_report.py index eb5d453f1db..fddc2d4dd24 100644 --- a/base_report_to_printer/models/ir_actions_report.py +++ b/base_report_to_printer/models/ir_actions_report.py @@ -38,7 +38,7 @@ def onchange_printing_printer_id(self): @api.model def print_action_for_report_name(self, report_name): - """ Returns if the action is a direct print or pdf + """Returns if the action is a direct print or pdf Called from js """ @@ -130,7 +130,7 @@ def report_action(self, docids, data=None, config=True): return res def render_qweb_pdf(self, res_ids=None, data=None): - """ Generate a PDF and returns it. + """Generate a PDF and returns it. If the action configured on the report is server, it prints the generated document as well. diff --git a/base_report_to_printer/models/printing_printer.py b/base_report_to_printer/models/printing_printer.py index df9b9ca6d05..690fc902d8d 100644 --- a/base_report_to_printer/models/printing_printer.py +++ b/base_report_to_printer/models/printing_printer.py @@ -122,7 +122,7 @@ def _prepare_update_from_cups(self, cups_connection, cups_printer): return vals def print_document(self, report, content, **print_opts): - """ Print a file + """Print a file Format could be pdf, qweb-pdf, raw, ... """ self.ensure_one() diff --git a/base_report_to_printer/static/src/js/qweb_action_manager.js b/base_report_to_printer/static/src/js/qweb_action_manager.js index 9fe0b8535c5..0113bc8484e 100644 --- a/base_report_to_printer/static/src/js/qweb_action_manager.js +++ b/base_report_to_printer/static/src/js/qweb_action_manager.js @@ -1,4 +1,4 @@ -odoo.define("base_report_to_printer.print", function(require) { +odoo.define("base_report_to_printer.print", function (require) { "use strict"; var ActionManager = require("web.ActionManager"); @@ -6,7 +6,7 @@ odoo.define("base_report_to_printer.print", function(require) { var _t = core._t; ActionManager.include({ - _triggerDownload: function(action, options, type) { + _triggerDownload: function (action, options, type) { var self = this; var _super = this._super; if (type === "pdf") { @@ -14,7 +14,7 @@ odoo.define("base_report_to_printer.print", function(require) { model: "ir.actions.report", method: "print_action_for_report_name", args: [action.report_name], - }).then(function(print_action) { + }).then(function (print_action) { if (print_action && print_action.action === "server") { self._rpc({ model: "ir.actions.report", @@ -23,7 +23,7 @@ odoo.define("base_report_to_printer.print", function(require) { kwargs: {data: action.data || {}}, context: action.context || {}, }).then( - function() { + function () { self.do_notify( _t("Report"), _.str.sprintf( @@ -32,7 +32,7 @@ odoo.define("base_report_to_printer.print", function(require) { ) ); }, - function() { + function () { self.do_notify( _t("Report"), _.str.sprintf( 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 0d89763c01f..eee37ed2003 100644 --- a/base_report_to_printer/tests/test_ir_actions_report.py +++ b/base_report_to_printer/tests/test_ir_actions_report.py @@ -133,8 +133,7 @@ def test_behaviour_user_action(self): ) def test_behaviour_printing_action_on_wrong_user(self): - """ It should return the action and printer ignoring printing action - """ + """It should return the action and printer ignoring printing action""" report = self.Model.search([], limit=1) self.env.user.printing_action = "client" printing_action = self.new_printing_action() @@ -147,8 +146,7 @@ def test_behaviour_printing_action_on_wrong_user(self): ) def test_behaviour_printing_action_on_wrong_report(self): - """ It should return the action and printer ignoring printing action - """ + """It should return the action and printer ignoring printing action""" report = self.Model.search([], limit=1) self.env.user.printing_action = "client" printing_action = self.new_printing_action() @@ -162,8 +160,8 @@ def test_behaviour_printing_action_on_wrong_report(self): ) def test_behaviour_printing_action_with_no_printer(self): - """ It should return the action from printing action and printer from - other + """It should return the action from printing action and printer from + other """ report = self.Model.search([], limit=1) self.env.user.printing_action = "client" @@ -196,8 +194,8 @@ def test_behaviour_printing_action_with_printer(self): ) def test_behaviour_printing_action_user_defaults(self): - """ It should return the action and printer from user with printing - action + """It should return the action and printer from user with printing + action """ report = self.Model.search([], limit=1) self.env.user.printing_action = "client" diff --git a/base_report_to_printer/tests/test_printing_report_xml_action.py b/base_report_to_printer/tests/test_printing_report_xml_action.py index 6c0c13debc8..af0e1dc55ec 100644 --- a/base_report_to_printer/tests/test_printing_report_xml_action.py +++ b/base_report_to_printer/tests/test_printing_report_xml_action.py @@ -41,8 +41,8 @@ def new_printer(self): ) def test_behaviour(self): - """ It should return some action's data, unless called on empty - recordset + """It should return some action's data, unless called on empty + recordset """ xml_action = self.new_record() self.assertEqual( diff --git a/base_report_to_printer/tests/test_printing_server.py b/base_report_to_printer/tests/test_printing_server.py index d529e4a834e..a48f263e321 100644 --- a/base_report_to_printer/tests/test_printing_server.py +++ b/base_report_to_printer/tests/test_printing_server.py @@ -98,7 +98,8 @@ def test_update_archived_printers(self, cups): cups.Connection().getPrinters().get.return_value = False self.Model.action_update_printers() self.assertEqual( - "unavailable", rec_id.status, + "unavailable", + rec_id.status, ) @mock.patch("%s.cups" % model) diff --git a/base_report_to_printer/tests/test_report.py b/base_report_to_printer/tests/test_report.py index cc9c8237006..72630da75d8 100644 --- a/base_report_to_printer/tests/test_report.py +++ b/base_report_to_printer/tests/test_report.py @@ -82,8 +82,7 @@ def test_can_print_report_false(self): self.assertFalse(res) def test_render_qweb_pdf_not_printable(self): - """ It should print the report, only if it is printable - """ + """It should print the report, only if it is printable""" with mock.patch( "odoo.addons.base_report_to_printer.models." "printing_printer.PrintingPrinter." @@ -93,8 +92,7 @@ def test_render_qweb_pdf_not_printable(self): print_document.assert_not_called() def test_render_qweb_pdf_printable(self): - """ It should print the report, only if it is printable - """ + """It should print the report, only if it is printable""" with mock.patch( "odoo.addons.base_report_to_printer.models." "printing_printer.PrintingPrinter."