mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[14.0][FIX] base_report_to_printer: Manage text print_document()
This commit is contained in:
committed by
John Herholz
parent
ba9d89622d
commit
2246cba708
@@ -8,6 +8,8 @@
|
||||
from odoo import _, api, exceptions, fields, models
|
||||
from odoo.tools.safe_eval import safe_eval, time
|
||||
|
||||
REPORT_TYPES = {"qweb-pdf": "pdf", "qweb-text": "text"}
|
||||
|
||||
|
||||
class IrActionsReport(models.Model):
|
||||
_inherit = "ir.actions.report"
|
||||
@@ -99,9 +101,16 @@ class IrActionsReport(models.Model):
|
||||
|
||||
def print_document(self, record_ids, data=None):
|
||||
"""Print a document, do not return the document file"""
|
||||
document, doc_format = self.with_context(
|
||||
must_skip_send_to_printer=True
|
||||
)._render_qweb_pdf(self.report_name, record_ids, data=data)
|
||||
report_type = REPORT_TYPES.get(self.report_type)
|
||||
if not report_type:
|
||||
raise exceptions.UserError(
|
||||
_("This report type (%s) is not supported by direct printing!")
|
||||
% str(self.report_type)
|
||||
)
|
||||
method_name = "_render_qweb_%s" % (report_type)
|
||||
document, doc_format = getattr(
|
||||
self.with_context(must_skip_send_to_printer=True), method_name
|
||||
)(self.report_name, record_ids, data=data)
|
||||
behaviour = self.behaviour()
|
||||
printer = behaviour.pop("printer", None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user