changeset 0a19f9fcf8b4 in modules/company:default details: https://hg.tryton.org/modules/company?cmd=changeset&node=0a19f9fcf8b4 description: Replace pytz by trytond timezone tools
issue11756 review421841003 diffstat: company.py | 7 ++----- ir.py | 10 +++------- setup.py | 3 --- 3 files changed, 5 insertions(+), 15 deletions(-) diffs (62 lines): diff -r 34fba3335a3e -r 0a19f9fcf8b4 company.py --- a/company.py Mon Oct 03 09:31:34 2022 +0200 +++ b/company.py Sun Oct 09 13:27:55 2022 +0200 @@ -4,14 +4,11 @@ from trytond.pool import Pool from trytond.pyson import Eval, If from trytond.report import Report +from trytond.tools import timezone as tz from trytond.transaction import Transaction from trytond.wizard import Button, StateTransition, StateView, Wizard -try: - import pytz - TIMEZONES = [(x, x) for x in pytz.common_timezones] -except ImportError: - TIMEZONES = [] +TIMEZONES = [(z, z) for z in tz.available_timezones()] TIMEZONES += [(None, '')] Transaction.cache_keys.update({'company', 'employee'}) diff -r 34fba3335a3e -r 0a19f9fcf8b4 ir.py --- a/ir.py Mon Oct 03 09:31:34 2022 +0200 +++ b/ir.py Sun Oct 09 13:27:55 2022 +0200 @@ -1,13 +1,9 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -try: - import pytz -except ImportError: - pytz = None - from trytond.model import ( EvalEnvironment, ModelSQL, ModelView, dualmethod, fields) from trytond.pool import Pool, PoolMeta +from trytond.tools import timezone as tz from trytond.transaction import Transaction @@ -41,8 +37,8 @@ company_id = Transaction().context.get('company') if timezone is None and company_id: company = Company(company_id) - if company.timezone and pytz: - timezone = pytz.timezone(company.timezone) + if company.timezone: + timezone = tz.ZoneInfo(company.timezone) return super(Date, cls).today(timezone=timezone) diff -r 34fba3335a3e -r 0a19f9fcf8b4 setup.py --- a/setup.py Mon Oct 03 09:31:34 2022 +0200 +++ b/setup.py Sun Oct 09 13:27:55 2022 +0200 @@ -140,9 +140,6 @@ license='GPL-3', python_requires='>=3.7', install_requires=requires, - extras_require={ - 'timezone': ['pytz'], - }, dependency_links=dependency_links, zip_safe=False, entry_points="""