Browse Source

IMP acc_export_csv: reinitialize StringIO instead of flush

pull/756/head
David Beal 5 years ago
committed by Kévin Roche
parent
commit
ebf3aeb77e
  1. 8
      account_export_csv/wizard/account_export_csv.py
  2. 6
      account_export_csv/wizard/account_export_csv_view.xml

8
account_export_csv/wizard/account_export_csv.py

@ -38,11 +38,9 @@ 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)
# 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()
# seek() or truncate() have side effect then we reinitialize StringIO
# https://stackoverflow.com/questions/4330812/how-do-i-clear-a-stringio-object
self.queue = StringIO()
def writerows(self, rows): def writerows(self, rows):
for row in rows: for row in rows:

6
account_export_csv/wizard/account_export_csv_view.xml

@ -33,9 +33,9 @@
<field name="data" filename="export_filename"/> <field name="data" filename="export_filename"/>
</group> </group>
<footer> <footer>
<button name="action_manual_export_account" string="Trial Balance" type="object" icon="fa-cog" class="oe_highlight"/>
<button name="action_manual_export_analytic" string="Analytic Balance (with accounts)" type="object" icon="fa-cog" class="oe_highlight"/>
<button name="action_manual_export_journal_entries" string="Journal Entries" type="object" icon="fa-cog" class="oe_highlight"/>
<button name="action_manual_export_account" string="Trial Balance" type="object" icon="fa-cog"/>
<button name="action_manual_export_analytic" string="Analytic Balance (with accounts)" type="object" icon="fa-cog"/>
<button name="action_manual_export_journal_entries" string="Journal Entries" type="object" icon="fa-cog"/>
or or
<button string="Close" class="oe_link" special="cancel" /> <button string="Close" class="oe_link" special="cancel" />
</footer> </footer>

Loading…
Cancel
Save