mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[14.0][IMP] base_report_to_printer: Add tests for text documents
This commit is contained in:
@@ -101,7 +101,7 @@ class IrActionsReport(models.Model):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def print_document(self, record_ids, data=None):
|
def print_document(self, record_ids, data=None):
|
||||||
""" Print a document, do not return the document file """
|
"""Print a document, do not return the document file"""
|
||||||
report_type = REPORT_TYPES.get(self.report_type)
|
report_type = REPORT_TYPES.get(self.report_type)
|
||||||
if not report_type:
|
if not report_type:
|
||||||
raise exceptions.UserError(
|
raise exceptions.UserError(
|
||||||
|
|||||||
@@ -43,6 +43,14 @@ class TestReport(common.HttpCase):
|
|||||||
"report_name": "base_report_to_printer.test",
|
"report_name": "base_report_to_printer.test",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
self.report_text = self.Model.create(
|
||||||
|
{
|
||||||
|
"name": "Test",
|
||||||
|
"report_type": "qweb-text",
|
||||||
|
"model": "res.partner",
|
||||||
|
"report_name": "base_report_to_printer.test",
|
||||||
|
}
|
||||||
|
)
|
||||||
self.partners = self.env["res.partner"]
|
self.partners = self.env["res.partner"]
|
||||||
for n in range(5):
|
for n in range(5):
|
||||||
self.partners += self.env["res.partner"].create({"name": "Test %d" % n})
|
self.partners += self.env["res.partner"].create({"name": "Test %d" % n})
|
||||||
@@ -109,6 +117,24 @@ class TestReport(common.HttpCase):
|
|||||||
tray=False,
|
tray=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_render_qweb_text_printable(self):
|
||||||
|
"""It should print the report, only if it is printable"""
|
||||||
|
with mock.patch(
|
||||||
|
"odoo.addons.base_report_to_printer.models."
|
||||||
|
"printing_printer.PrintingPrinter."
|
||||||
|
"print_document"
|
||||||
|
) as print_document:
|
||||||
|
self.report_text.property_printing_action_id.action_type = "server"
|
||||||
|
self.report_text.printing_printer_id = self.new_printer()
|
||||||
|
document = self.report_text._render_qweb_text(self.partners.ids)
|
||||||
|
print_document.assert_called_once_with(
|
||||||
|
self.report_text,
|
||||||
|
document[0],
|
||||||
|
action="server",
|
||||||
|
doc_format="qweb-text",
|
||||||
|
tray=False,
|
||||||
|
)
|
||||||
|
|
||||||
def test_print_document_not_printable(self):
|
def test_print_document_not_printable(self):
|
||||||
"""It should print the report, regardless of the defined behaviour"""
|
"""It should print the report, regardless of the defined behaviour"""
|
||||||
self.report.printing_printer_id = self.new_printer()
|
self.report.printing_printer_id = self.new_printer()
|
||||||
|
|||||||
Reference in New Issue
Block a user