mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[IMP] base_report_to_printer: black, isort, prettier
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user