From ba824215c1e31c29eb336472d3ee7e7c16c70bb1 Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Wed, 11 Dec 2024 16:50:02 +0100 Subject: [PATCH] delete invoice-report if type != pdf --- wizard_runreport.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wizard_runreport.py b/wizard_runreport.py index 621c7d7..183126b 100644 --- a/wizard_runreport.py +++ b/wizard_runreport.py @@ -103,8 +103,22 @@ class RunXRechnungReport(Wizard): invoices = Invoice.search([ ('id', '=', data['invoice']), ('type', '=', 'out')]) - to_generate = [x.id for x in invoices if not x.invoice_report_cache] + # check if stored report is pdf + to_delete_report = [ + x + for x in invoices + if x.invoice_report_cache and (x.invoice_report_format != 'pdf')] + + # delete reports + if to_delete_report: + Invoice.write(*[ + to_delete_report, { + 'invoice_report_cache': None, + 'invoice_report_cache_id': None, + 'invoice_report_format': None}]) + + to_generate = [x.id for x in invoices if not x.invoice_report_cache] if to_generate: report_action = XReport.get_used_report()