Support Binary field in CSV import/export

issue10350
review346101002
This commit is contained in:
Cédric Krier committed 2021-05-18 22:08:59 +02:00
1 parent d33cc0e5fe
commit f470dacd3e
3 files changed
+8

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
* Support Binary field in CSV import/export
Version 6.0.0 - 2021-05-03
* Bug fixes (see mercurial logs for details)
* Support printing zip archive
+3
View File
@@ -1,5 +1,6 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import base64
import csv
import datetime
import os
@@ -426,6 +427,8 @@ class WinExport(WinCSV):
val = int(val)
if i == 0 and indent and isinstance(val, str):
val = ' ' * indent + val
if isinstance(val, bytes):
val = base64.b64encode(val).decode('utf-8')
row.append(val)
return row
+3
View File
@@ -1,5 +1,6 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import base64
import csv
import gettext
import locale
@@ -208,6 +209,8 @@ class WinImport(WinCSV):
val = Decimal(locale.delocalize(val))
elif type_ in ['date', 'datetime']:
val = date_parse(val, common.date_format())
elif type_ == 'binary':
val = base64.b64decode(val)
row.append(val)
data.append(row)
try: