Replace pytz by trytond timezone tools
issue11756 review421841003
This commit is contained in:
+2
-5
@@ -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'})
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user