delete invoice-report if type != pdf

This commit is contained in:
Frederik Jaeckel 2024-12-11 16:50:02 +01:00
parent e0cd1a08f1
commit ba824215c1

View file

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