From e5b0dee319bf4a48f651f739294bf7139be8bed4 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Fri, 6 Dec 2024 15:43:55 +0100 Subject: [PATCH] [FIX] printing_auto_base: use proper Error --- printing_auto_base/models/printing_auto.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/printing_auto_base/models/printing_auto.py b/printing_auto_base/models/printing_auto.py index 5f3ed8bf6dc..88a8aaa41e7 100644 --- a/printing_auto_base/models/printing_auto.py +++ b/printing_auto_base/models/printing_auto.py @@ -65,11 +65,11 @@ class PrintingAuto(models.Model): def _check_data_source(self): for rec in self: if rec.data_source == "report" and not rec.report_id: - raise UserError(_("Report is not set")) + raise ValidationError(_("Report is not set")) if rec.data_source == "attachment" and ( not rec.attachment_domain or rec.attachment_domain == "[]" ): - raise UserError(_("Attachment domain is not set")) + raise ValidationError(_("Attachment domain is not set")) def _get_behaviour(self): if self.printer_id: @@ -86,7 +86,7 @@ def _get_record(self, record): try: return safe_eval(f"obj.{self.record_change}", {"obj": record}) except Exception as e: - raise ValidationError( + raise UserError( _("The Record change could not be applied because: %s") % str(e) ) from e return record @@ -118,7 +118,7 @@ def _generate_data_from_attachment(self, record): domain = self._prepare_attachment_domain(record) attachments = self.env["ir.attachment"].search(domain) if not attachments: - raise ValidationError(_("No attachment was found.")) + raise UserError(_("No attachment was found.")) return [base64.b64decode(a.datas) for a in attachments] def _generate_data_from_report(self, record):