diff --git a/CHANGELOG b/CHANGELOG index be3d76ff0f..a9f335b0a5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 --git a/tryton/gui/window/win_export.py b/tryton/gui/window/win_export.py index 0a8775bfee..275a9adac8 100644 --- a/tryton/gui/window/win_export.py +++ b/tryton/gui/window/win_export.py @@ -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 diff --git a/tryton/gui/window/win_import.py b/tryton/gui/window/win_import.py index 409f84d0e6..5bfe04dacf 100644 --- a/tryton/gui/window/win_import.py +++ b/tryton/gui/window/win_import.py @@ -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: