Am Montag, 15. Juni 2015 13:35:04 UTC+2 schrieb Antonio Roncero:
>
> Hi,
>
> i want to write a report from proteus. I use the code below
>
> def download_invoice(invoice_id):
> report=Report('account.invoice')
> Invoice = Model.get('account.invoice')
> invoices = Invoice.find(condition=['id','=',invoice_id])
> type_, data, print_, name = report.execute(invoices, {})
> target = open(name+'.odt', 'w')
> newFileByteArray = bytearray(data)
> target.write(newFileByteArray)
>
>
> The file 'Invoice - FV0005.odt' is created fine but is emty. What is the
> correct way to do it?
>
> Thanks
>
If the invoice is already created I only save the
"invoice.invoice_report_cache.data"
f = codecs.open(filename, 'wb')
f.write(invoice.invoice_report_cache.data)
f.close()
regards