增加日志
This commit is contained in:
@@ -3,9 +3,12 @@ import qrcode
|
||||
from reportlab.pdfgen import canvas
|
||||
from reportlab.lib.pagesizes import A4
|
||||
from PIL import Image
|
||||
import logging
|
||||
from reportlab.lib.utils import ImageReader
|
||||
from odoo import models, fields, api
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class JikimoPrinting(models.AbstractModel):
|
||||
_name = 'jikimo.printing'
|
||||
|
||||
@@ -42,6 +45,7 @@ class JikimoPrinting(models.AbstractModel):
|
||||
# 获取PDF内容并打印
|
||||
pdf_content = pdf_buffer.getvalue()
|
||||
printer = self.env['printing.printer'].get_default()
|
||||
_logger.info(f"打印内容: {pdf_content}")
|
||||
printer.print_document(report=None, content=pdf_content, doc_format='pdf')
|
||||
|
||||
# 清理资源
|
||||
@@ -51,9 +55,7 @@ class JikimoPrinting(models.AbstractModel):
|
||||
def print_pdf(self, pdf_data):
|
||||
"""
|
||||
打印PDF
|
||||
"""
|
||||
if isinstance(pdf_data, str):
|
||||
pdf_data = pdf_data.encode()
|
||||
|
||||
"""
|
||||
printer = self.env['printing.printer'].get_default()
|
||||
_logger.info(f"打印内容: {pdf_data}")
|
||||
printer.print_document(report=None, content = pdf_data, doc_format='pdf')
|
||||
Reference in New Issue
Block a user