Do not fail if pytz module can not be imported

pytz is an optional dependency.
This commit is contained in:
Cédric Krier committed 2019-12-05 23:10:39 +01:00
1 parent 691079fc58
commit a50af0b48e
1 file changed
+5 -2
+5 -2
View File
@@ -1,6 +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.
import pytz
try:
import pytz
except ImportError:
pytz = None
from trytond.model import ModelSQL, ModelView, fields, dualmethod
from trytond.pool import PoolMeta, Pool
@@ -40,7 +43,7 @@ class Date(metaclass=PoolMeta):
company_id = Transaction().context.get('company')
if timezone is None and company_id:
company = Company(company_id)
if company.timezone:
if company.timezone and pytz:
timezone = pytz.timezone(company.timezone)
return super(Date, cls).today(timezone=timezone)