Browse Source

FIX acc_export_csv: use truncate/seek instead of StringIO()

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

6
account_export_csv/wizard/account_export_csv.py

@ -38,9 +38,11 @@ class AccountingWriter(object):
data = self.encoder.encode(data) data = self.encoder.encode(data)
# write to the target stream # write to the target stream
self.stream.write(data) self.stream.write(data)
# seek() or truncate() have side effect then we reinitialize StringIO
# seek() or truncate() have side effect if not used combinated
self.queue.truncate(0)
self.queue.seek(0)
# https://stackoverflow.com/questions/4330812/how-do-i-clear-a-stringio-object # https://stackoverflow.com/questions/4330812/how-do-i-clear-a-stringio-object
self.queue = StringIO()
# It fails when you use `self.queue = StringIO()` only add one line
def writerows(self, rows): def writerows(self, rows):
for row in rows: for row in rows:

Loading…
Cancel
Save