From debf8aabfa7896f9bceb6c5a1b76aad2e612f8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 25 Jan 2023 00:53:43 +0100 Subject: [PATCH] Use tzinfo.tzname instead of key to display timezone on cron key is a specific to ZoneInfo implementation when tzname is part tzinfo API. Closes #12036 --- trytond/trytond/ir/cron.py | 2 +- trytond/trytond/tests/test_ir.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/trytond/trytond/ir/cron.py b/trytond/trytond/ir/cron.py index 9e78798f1f..a9067c8084 100644 --- a/trytond/trytond/ir/cron.py +++ b/trytond/trytond/ir/cron.py @@ -103,7 +103,7 @@ class Cron(DeactivableMixin, ModelSQL, ModelView): table_h.not_null_action('next_call', 'remove') def get_timezone(self, name): - return tz.SERVER.key + return tz.SERVER.tzname(datetime.datetime.now()) @classmethod def check_xml_record(cls, crons, values): diff --git a/trytond/trytond/tests/test_ir.py b/trytond/trytond/tests/test_ir.py index 0857c4e653..68a2a8bba3 100644 --- a/trytond/trytond/tests/test_ir.py +++ b/trytond/trytond/tests/test_ir.py @@ -462,5 +462,12 @@ class IrCronTestCase(unittest.TestCase): cron.compute_next_call(datetime.datetime(2022, 11, 6, 7, 30)), datetime.datetime(2022, 11, 6, 8, 30)) + @with_transaction() + def test_get_timezone(self): + "Test get_timezone" + cron = self._get_cron() + + self.assertIsInstance(cron.get_timezone('timezone'), str) + del ModuleTestCase