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()