Replace pytz by trytond timezone tools

issue11756
review421841003
This commit is contained in:
Cédric Krier
2022-10-09 13:27:55 +02:00
parent 39f86cfa60
commit 5808abd6db
3 changed files with 5 additions and 15 deletions
+2 -5
View File
@@ -4,14 +4,11 @@ from trytond.model import ModelSQL, ModelView, fields
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'})
+3 -7
View File
@@ -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 @@ class Date(metaclass=PoolMeta):
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)
-3
View File
@@ -140,9 +140,6 @@ setup(name=name,
license='GPL-3',
python_requires='>=3.7',
install_requires=requires,
extras_require={
'timezone': ['pytz'],
},
dependency_links=dependency_links,
zip_safe=False,
entry_points="""