Skip to content

Commit

Permalink
[IMP] base_report_to_printer: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosRoca13 authored and flachica committed Oct 1, 2022
1 parent 47f441b commit 5e29d49
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 23 deletions.
4 changes: 2 additions & 2 deletions base_report_to_printer/models/ir_actions_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion base_report_to_printer/models/printing_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions base_report_to_printer/static/src/js/qweb_action_manager.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
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");
var core = require("web.core");
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") {
this._rpc({
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",
Expand All @@ -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(
Expand All @@ -32,7 +32,7 @@ odoo.define("base_report_to_printer.print", function(require) {
)
);
},
function() {
function () {
self.do_notify(
_t("Report"),
_.str.sprintf(
Expand Down
14 changes: 6 additions & 8 deletions base_report_to_printer/tests/test_ir_actions_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion base_report_to_printer/tests/test_printing_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions base_report_to_printer/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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."
Expand Down

0 comments on commit 5e29d49

Please sign in to comment.