From 3d937b85c937c066b10a622e09b68c87976fdbaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 24 Apr 2025 09:59:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=9C=BA=E5=8F=B0=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81=E4=BD=BF=E7=94=A8A4=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_printing/models/maintenance_printing.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jikimo_printing/models/maintenance_printing.py b/jikimo_printing/models/maintenance_printing.py index 9c7ac8df..befafccf 100644 --- a/jikimo_printing/models/maintenance_printing.py +++ b/jikimo_printing/models/maintenance_printing.py @@ -24,7 +24,10 @@ class MaintenancePrinting(models.Model): # 切换成A4打印机 printer = self.env['printing.printer'].get_default() - printer.print_document(report=None, content = qr_code_data) + try: + printer.print_document(report=None, content = qr_code_data) + except Exception as e: + raise UserError(f"打印失败: {str(e)}") # def generate_zpl_code(self, code):