[FIX] account: set main attachment only for posted invoices
When printing a draft invoice, it raises an error. The error comes from fix #65320: the latter registers the printed invoice as main attachment, but this needs to be done only with posted invoices. OPW-2427247 closes odoo/odoo#66563 X-original-commit: 49a57dd5b34b66733564b31ed861fe9bfcbda2b3 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com> Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
This commit is contained in:
@@ -28,6 +28,6 @@ class IrActionsReport(models.Model):
|
||||
if self.report_name == 'account.report_original_vendor_bill':
|
||||
return None
|
||||
res = super(IrActionsReport, self)._postprocess_pdf_report(record, buffer)
|
||||
if self.model == 'account.move' and record.is_sale_document(include_receipts=True):
|
||||
if self.model == 'account.move' and record.state == 'posted' and record.is_sale_document(include_receipts=True):
|
||||
self.retrieve_attachment(record).register_as_main_attachment(force=False)
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user