changeset 6ab5b2e5e14c in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset&node=6ab5b2e5e14c
description:
Support Binary field in CSV import/export
issue10350
review346101002
diffstat:
CHANGELOG | 2 ++
tryton/gui/window/win_export.py | 3 +++
tryton/gui/window/win_import.py | 3 +++
3 files changed, 8 insertions(+), 0 deletions(-)
diffs (47 lines):
diff -r 4a35f57d3356 -r 6ab5b2e5e14c CHANGELOG
--- a/CHANGELOG Sun May 16 18:00:27 2021 +0200
+++ b/CHANGELOG Tue May 18 22:08:59 2021 +0200
@@ -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
diff -r 4a35f57d3356 -r 6ab5b2e5e14c tryton/gui/window/win_export.py
--- a/tryton/gui/window/win_export.py Sun May 16 18:00:27 2021 +0200
+++ b/tryton/gui/window/win_export.py Tue May 18 22:08:59 2021 +0200
@@ -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 @@
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
diff -r 4a35f57d3356 -r 6ab5b2e5e14c tryton/gui/window/win_import.py
--- a/tryton/gui/window/win_import.py Sun May 16 18:00:27 2021 +0200
+++ b/tryton/gui/window/win_import.py Tue May 18 22:08:59 2021 +0200
@@ -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 @@
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: