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:
committed by
John Herholz
parent
27b944ae03
commit
d03814d170
@@ -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.
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -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,7 +160,7 @@ 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)
|
||||||
@@ -196,7 +194,7 @@ 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)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ 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()
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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."
|
||||||
|
|||||||
Reference in New Issue
Block a user