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:
@@ -9,6 +9,8 @@ from time import time
|
|||||||
from odoo import _, api, exceptions, fields, models
|
from odoo import _, api, exceptions, fields, models
|
||||||
from odoo.tools.safe_eval import safe_eval
|
from odoo.tools.safe_eval import safe_eval
|
||||||
|
|
||||||
|
REPORT_TYPES = {"qweb-pdf": "pdf", "qweb-text": "text"}
|
||||||
|
|
||||||
|
|
||||||
class IrActionsReport(models.Model):
|
class IrActionsReport(models.Model):
|
||||||
_inherit = "ir.actions.report"
|
_inherit = "ir.actions.report"
|
||||||
@@ -99,10 +101,17 @@ 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 """
|
||||||
document, doc_format = self.with_context(
|
report_type = REPORT_TYPES.get(self.report_type)
|
||||||
must_skip_send_to_printer=True
|
if not report_type:
|
||||||
)._render_qweb_pdf(record_ids, data=data)
|
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
|
||||||
|
)(record_ids, data=data)
|
||||||
behaviour = self.behaviour()
|
behaviour = self.behaviour()
|
||||||
printer = behaviour.pop("printer", None)
|
printer = behaviour.pop("printer", None)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user