[MIG] base_report_to_printer: Migration to 16.0

This commit is contained in:
hda
2022-12-07 09:33:25 +01:00
committed by trisdoan
parent 97f31f20b1
commit 5c77a2e440
5 changed files with 12 additions and 7 deletions

View File

@@ -7,7 +7,7 @@
{ {
"name": "Report to printer", "name": "Report to printer",
"version": "15.0.1.0.0", "version": "16.0.1.0.0",
"category": "Generic Modules/Base", "category": "Generic Modules/Base",
"author": "Agile Business Group & Domsense, Pegueroles SCP, NaN," "author": "Agile Business Group & Domsense, Pegueroles SCP, NaN,"
" LasLabs, Camptocamp, Odoo Community Association (OCA)," " LasLabs, Camptocamp, Odoo Community Association (OCA),"

View File

@@ -101,7 +101,7 @@ class IrActionsReport(models.Model):
"""Print a document, do not return the document file""" """Print a document, do not return the document file"""
document, doc_format = self.with_context( document, doc_format = self.with_context(
must_skip_send_to_printer=True must_skip_send_to_printer=True
)._render_qweb_pdf(record_ids, data=data) )._render_qweb_pdf(self.report_name, record_ids, data=data)
behaviour = self.behaviour() behaviour = self.behaviour()
printer = behaviour.pop("printer", None) printer = behaviour.pop("printer", None)
@@ -141,13 +141,15 @@ class IrActionsReport(models.Model):
res["id"] = self.id res["id"] = self.id
return res return res
def _render_qweb_pdf(self, res_ids=None, data=None): def _render_qweb_pdf(self, report_ref, 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.
""" """
document, doc_format = super()._render_qweb_pdf(res_ids=res_ids, data=data) document, doc_format = super()._render_qweb_pdf(
report_ref=report_ref, res_ids=res_ids, data=data
)
behaviour = self.behaviour() behaviour = self.behaviour()
printer = behaviour.pop("printer", None) printer = behaviour.pop("printer", None)

View File

@@ -12,3 +12,4 @@
* Rod Schouteden <rod@schout-it.be> * Rod Schouteden <rod@schout-it.be>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com> * Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
* Matias Peralta <mnp@adhoc.com.ar> * Matias Peralta <mnp@adhoc.com.ar>
* Hughes Damry <hughes.damry@acsone.eu>

View File

@@ -95,7 +95,7 @@ class TestPrintingServer(TransactionCase):
"""It should update status even if printer is archived""" """It should update status even if printer is archived"""
rec_id = self.new_printer() rec_id = self.new_printer()
rec_id.toggle_active() rec_id.toggle_active()
self.server.refresh() self.server.invalidate_model()
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(

View File

@@ -92,7 +92,7 @@ class TestReport(common.HttpCase):
"printing_printer.PrintingPrinter." "printing_printer.PrintingPrinter."
"print_document" "print_document"
) as print_document: ) as print_document:
self.report._render_qweb_pdf(self.partners.ids) self.report._render_qweb_pdf(self.report.report_name, self.partners.ids)
print_document.assert_not_called() print_document.assert_not_called()
def test_render_qweb_pdf_printable(self): def test_render_qweb_pdf_printable(self):
@@ -104,7 +104,9 @@ class TestReport(common.HttpCase):
) as print_document: ) as print_document:
self.report.property_printing_action_id.action_type = "server" self.report.property_printing_action_id.action_type = "server"
self.report.printing_printer_id = self.new_printer() self.report.printing_printer_id = self.new_printer()
document = self.report._render_qweb_pdf(self.partners.ids) document = self.report._render_qweb_pdf(
self.report.report_name, self.partners.ids
)
print_document.assert_called_once_with( print_document.assert_called_once_with(
self.report, self.report,
document[0], document[0],