FIX account_export_csv: use flush() instead of truncate()

pull/597/head
David Beal 2019-07-27 11:56:12 +02:00
parent c608201cff
commit c295e79f35
1 changed files with 7 additions and 2 deletions

View File

@ -38,12 +38,17 @@ class AccountingWriter(object):
data = self.encoder.encode(data)
# write to the target stream
self.stream.write(data)
# empty queue
self.queue.truncate(0)
# empty queue with seek() instead of truncate()
# see https://stackoverflow.com/a/9729516
# also problems with seek() if next line is shorter than previous
# chars of previous line are kept in the new one
self.queue.flush()
def writerows(self, rows):
for row in rows:
self.writerow(row)
# https://docs.python.org/3/library/io.html#io.IOBase.close
self.queue.close()
class AccountCSVExport(models.TransientModel):