From 696dff64d63c6b79696426bebe2c8e3ab9d45743 Mon Sep 17 00:00:00 2001 From: "Hubert Van de Walle (huvw)" Date: Thu, 19 Aug 2021 14:03:00 +0000 Subject: [PATCH] [FIX] account: don't print invoices for miscellaneous journal entries Step to follow - Trigger the Print > Invoices action - An error is displayed but the PDF is still attached Cause of the issue > The PDF is generated before the error Solution > Show an error earlier opw-2625480 closes odoo/odoo#75379 X-original-commit: b324ba12b4af2d00c696bc5c42896c7c431d863c Signed-off-by: Florian Gilbert --- addons/account/models/ir_actions_report.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/account/models/ir_actions_report.py b/addons/account/models/ir_actions_report.py index 27deaa9fe7e..eee5f8953b1 100644 --- a/addons/account/models/ir_actions_report.py +++ b/addons/account/models/ir_actions_report.py @@ -33,3 +33,9 @@ class IrActionsReport(models.Model): if attachment: attachment.register_as_main_attachment(force=False) return res + + @api.model + def render_qweb_pdf(self, res_ids=None, data=None): + if self.model == 'account.move' and any(not m.is_invoice(include_receipts=True) for m in self.env[self.model].browse(res_ids)): + raise UserError(_("Only invoices could be printed.")) + return super(IrActionsReport, self).render_qweb_pdf(res_ids, data)