Browse Source

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

pull/756/head
David Beal 5 years ago
committed by Kévin Roche
parent
commit
2ec367387e
  1. 9
      account_export_csv/wizard/account_export_csv.py

9
account_export_csv/wizard/account_export_csv.py

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

Loading…
Cancel
Save