From d95ef621814a30b7334263bb55ed7ff064a60c2d Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Tue, 9 May 2023 15:30:00 +0000 Subject: [PATCH] [FIX] account: display invoice report in journal items view Create an invoice Send & Print Go to Journal items Select created invoice line Issue: No preview is shown This occurs because the attachment was created with res_field 'invoice_pdf_report_file' When we search without res_field the method _search of ir.attachment will add ('res_field', '=', False) to the domain So we don't find the generated report opw-3301344 opw-3271602 closes odoo/odoo#122183 X-original-commit: 4a88945fb125716f4362252795e969f36b48391d Signed-off-by: Laurent Smet Signed-off-by: Grazioso Andrea (agr) --- addons/account/models/account_move_line.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index 8a17cfcd84e..a8d704c8be2 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -2878,7 +2878,11 @@ class AccountMoveLine(models.Model): def _get_attachment_domains(self): self.ensure_one() - domains = [[('res_model', '=', 'account.move'), ('res_id', '=', self.move_id.id)]] + domains = [[ + ('res_model', '=', 'account.move'), + ('res_id', '=', self.move_id.id), + ('res_field', 'in', (False, 'invoice_pdf_report_file')), + ]] if self.statement_id: domains.append([('res_model', '=', 'account.bank.statement'), ('res_id', '=', self.statement_id.id)]) if self.payment_id: