[IMP] base_report_to_printer: black, isort, prettier

This commit is contained in:
Carlos Roca
2021-01-12 09:33:27 +01:00
committed by John Herholz
parent 27b944ae03
commit d03814d170
7 changed files with 20 additions and 23 deletions

View File

@@ -38,7 +38,7 @@ class IrActionsReport(models.Model):
@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 @@ class IrActionsReport(models.Model):
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.

View File

@@ -122,7 +122,7 @@ class PrintingPrinter(models.Model):
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()

View File

@@ -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(

View File

@@ -133,8 +133,7 @@ class TestIrActionsReportXml(TransactionCase):
)
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 @@ class TestIrActionsReportXml(TransactionCase):
)
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 @@ class TestIrActionsReportXml(TransactionCase):
)
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 @@ class TestIrActionsReportXml(TransactionCase):
)
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"

View File

@@ -41,8 +41,8 @@ class TestPrintingReportXmlAction(TransactionCase):
)
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(

View File

@@ -98,7 +98,8 @@ class TestPrintingServer(TransactionCase):
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)

View File

@@ -82,8 +82,7 @@ class TestReport(common.HttpCase):
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 @@ class TestReport(common.HttpCase):
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."