I have modified the on_convert_report method to check if the report.ext is empty and if it is then to use the report.extension attribute that is set in the Reports client module
def on_convert_report(report):
print ("In on_convert_report\n")
try:
# import _winreg
# regpath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\soffice.exe"
# root = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, regpath)
# s_office = _winreg.QueryValue(root, "")
# else:
s_office = "D:\Programs\LibreOfficePortable\App\libreoffice\program\soffice.exe"
print ("report.report_filename:",report.report_filename)
print ("report.task.work_dir", report.task.work_dir)
if (report.ext):
extension = report.ext
print ("extension:",report.ext)
else:
extension = report.extension
print ("extension:",report.extension)
convertion = Popen([s_office, '--headless', '--convert-to', extension,
report.report_filename, '--outdir', os.path.join(report.task.work_dir, 'static', 'reports') ],
stderr=STDOUT,stdout=PIPE)#, shell=True)
out, err = convertion.communicate()
converted = True
except Exception as e:
print(e)
This change did the trick and now the report gets converted properly with the changed filename as I wanted
127.0.0.1 - - [25/Feb/2021 19:56:41] "POST /api HTTP/1.1" 200 -
Filename: COM-21-0001
In on_convert_report
report.report_filename: C:\bfmsagent\static\reports\COM-21-0001_25-02-2021.ods
report.task.work_dir C:\bfmsagent
extension: pdf
127.0.0.1 - - [25/Feb/2021 19:56:50] "POST /api HTTP/1.1" 200 -