From a50af0b48ef95cd3fcf54814b49d6b55ddfeff0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 5 Dec 2019 23:10:39 +0100 Subject: [PATCH] Do not fail if pytz module can not be imported pytz is an optional dependency. --- ir.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ir.py b/ir.py index 7a3b65d066..002b949244 100644 --- a/ir.py +++ b/ir.py @@ -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)