[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 trisdoan
parent 0700b15211
commit fdcb2ae235
7 changed files with 20 additions and 23 deletions

View File

@@ -38,7 +38,7 @@ class IrActionsReport(models.Model):
@api.model @api.model
def print_action_for_report_name(self, report_name): 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 Called from js
""" """
@@ -130,7 +130,7 @@ class IrActionsReport(models.Model):
return res return res
def render_qweb_pdf(self, res_ids=None, data=None): 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 If the action configured on the report is server, it prints the
generated document as well. generated document as well.

View File

@@ -122,7 +122,7 @@ class PrintingPrinter(models.Model):
return vals return vals
def print_document(self, report, content, **print_opts): def print_document(self, report, content, **print_opts):
""" Print a file """Print a file
Format could be pdf, qweb-pdf, raw, ... Format could be pdf, qweb-pdf, raw, ...
""" """
self.ensure_one() 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"; "use strict";
var ActionManager = require("web.ActionManager"); var ActionManager = require("web.ActionManager");
@@ -6,7 +6,7 @@ odoo.define("base_report_to_printer.print", function(require) {
var _t = core._t; var _t = core._t;
ActionManager.include({ ActionManager.include({
_triggerDownload: function(action, options, type) { _triggerDownload: function (action, options, type) {
var self = this; var self = this;
var _super = this._super; var _super = this._super;
if (type === "pdf") { if (type === "pdf") {
@@ -14,7 +14,7 @@ odoo.define("base_report_to_printer.print", function(require) {
model: "ir.actions.report", model: "ir.actions.report",
method: "print_action_for_report_name", method: "print_action_for_report_name",
args: [action.report_name], args: [action.report_name],
}).then(function(print_action) { }).then(function (print_action) {
if (print_action && print_action.action === "server") { if (print_action && print_action.action === "server") {
self._rpc({ self._rpc({
model: "ir.actions.report", model: "ir.actions.report",
@@ -23,7 +23,7 @@ odoo.define("base_report_to_printer.print", function(require) {
kwargs: {data: action.data || {}}, kwargs: {data: action.data || {}},
context: action.context || {}, context: action.context || {},
}).then( }).then(
function() { function () {
self.do_notify( self.do_notify(
_t("Report"), _t("Report"),
_.str.sprintf( _.str.sprintf(
@@ -32,7 +32,7 @@ odoo.define("base_report_to_printer.print", function(require) {
) )
); );
}, },
function() { function () {
self.do_notify( self.do_notify(
_t("Report"), _t("Report"),
_.str.sprintf( _.str.sprintf(

View File

@@ -133,8 +133,7 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_printing_action_on_wrong_user(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) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
printing_action = self.new_printing_action() printing_action = self.new_printing_action()
@@ -147,8 +146,7 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_printing_action_on_wrong_report(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) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
printing_action = self.new_printing_action() printing_action = self.new_printing_action()
@@ -162,8 +160,8 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_printing_action_with_no_printer(self): def test_behaviour_printing_action_with_no_printer(self):
""" It should return the action from printing action and printer from """It should return the action from printing action and printer from
other other
""" """
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
@@ -196,8 +194,8 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_printing_action_user_defaults(self): def test_behaviour_printing_action_user_defaults(self):
""" It should return the action and printer from user with printing """It should return the action and printer from user with printing
action action
""" """
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"

View File

@@ -41,8 +41,8 @@ class TestPrintingReportXmlAction(TransactionCase):
) )
def test_behaviour(self): def test_behaviour(self):
""" It should return some action's data, unless called on empty """It should return some action's data, unless called on empty
recordset recordset
""" """
xml_action = self.new_record() xml_action = self.new_record()
self.assertEqual( self.assertEqual(

View File

@@ -98,7 +98,8 @@ class TestPrintingServer(TransactionCase):
cups.Connection().getPrinters().get.return_value = False cups.Connection().getPrinters().get.return_value = False
self.Model.action_update_printers() self.Model.action_update_printers()
self.assertEqual( self.assertEqual(
"unavailable", rec_id.status, "unavailable",
rec_id.status,
) )
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)

View File

@@ -82,8 +82,7 @@ class TestReport(common.HttpCase):
self.assertFalse(res) self.assertFalse(res)
def test_render_qweb_pdf_not_printable(self): 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( with mock.patch(
"odoo.addons.base_report_to_printer.models." "odoo.addons.base_report_to_printer.models."
"printing_printer.PrintingPrinter." "printing_printer.PrintingPrinter."
@@ -93,8 +92,7 @@ class TestReport(common.HttpCase):
print_document.assert_not_called() print_document.assert_not_called()
def test_render_qweb_pdf_printable(self): 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( with mock.patch(
"odoo.addons.base_report_to_printer.models." "odoo.addons.base_report_to_printer.models."
"printing_printer.PrintingPrinter." "printing_printer.PrintingPrinter."