changeset 063dcb2cdce1 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=063dcb2cdce1
description:
        Support timedelta in CSV import/export

        issue9220
        review297531002
diffstat:

 CHANGELOG                       |  1 +
 tryton/gui/window/win_export.py |  5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)

diffs (23 lines):

diff -r ebc04645fed0 -r 063dcb2cdce1 CHANGELOG
--- a/CHANGELOG Sun Oct 11 16:10:38 2020 +0200
+++ b/CHANGELOG Sun Oct 11 19:04:16 2020 +0200
@@ -1,3 +1,4 @@
+* Format timedelta in CSV export
 * Manage symbol widget
 * Fallback to model name as title
 * Manage deletable and writable state
diff -r ebc04645fed0 -r 063dcb2cdce1 tryton/gui/window/win_export.py
--- a/tryton/gui/window/win_export.py   Sun Oct 11 16:10:38 2020 +0200
+++ b/tryton/gui/window/win_export.py   Sun Oct 11 19:04:16 2020 +0200
@@ -390,6 +390,11 @@
                     val = val.strftime(common.date_format() + ' %X')
                 elif isinstance(val, datetime.date):
                     val = val.strftime(common.date_format())
+                elif isinstance(val, datetime.timedelta):
+                    val = common.timedelta.format(
+                        val, {'s': 1, 'm': 60, 'h': 60 * 60})
+            elif isinstance(val, datetime.timedelta):
+                val = val.total_seconds()
             elif isinstance(val, bool):
                 val = int(val)
             row.append(val)

Reply via email to