changeset 320173731993 in modules/product_cost_history:default
details: 
https://hg.tryton.org/modules/product_cost_history?cmd=changeset&node=320173731993
description:
        Replace pytz by trytond timezone tools

        issue11756
        review421841003
diffstat:

 product.py |  13 ++++---------
 setup.py   |   1 -
 2 files changed, 4 insertions(+), 10 deletions(-)

diffs (47 lines):

diff -r 1e611c15931f -r 320173731993 product.py
--- a/product.py        Fri Sep 30 22:41:34 2022 +0200
+++ b/product.py        Sun Oct 09 13:27:55 2022 +0200
@@ -5,14 +5,10 @@
 from sql.conditionals import Coalesce
 from sql.functions import CurrentTimestamp, LastValue
 
-try:
-    import pytz
-except ImportError:
-    pytz = None
-
 from trytond.model import ModelSQL, ModelView, fields
 from trytond.modules.product import round_price
 from trytond.pool import Pool, PoolMeta
+from trytond.tools import timezone as tz
 from trytond.transaction import Transaction
 
 
@@ -42,13 +38,12 @@
             datetime = context['_datetime']
             company = pattern.get(
                 'company', Transaction().context.get('company'))
-            if pytz and company:
+            if company:
                 company = Company(company)
                 if company.timezone:
-                    timezone = pytz.timezone(company.timezone)
+                    timezone = tz.ZoneInfo(company.timezone)
                     datetime = (
-                        pytz.utc.localize(datetime, is_dst=None)
-                        .astimezone(timezone))
+                        datetime.replace(tzinfo=tz.UTC).astimezone(timezone))
             cost_price = self.get_cost_price_at(datetime.date(), **pattern)
             if cost_price is not None:
                 return cost_price
diff -r 1e611c15931f -r 320173731993 setup.py
--- a/setup.py  Fri Sep 30 22:41:34 2022 +0200
+++ b/setup.py  Sun Oct 09 13:27:55 2022 +0200
@@ -140,7 +140,6 @@
     install_requires=requires,
     extras_require={
         'test': tests_require,
-        'timezone': ['pytz'],
         },
     dependency_links=dependency_links,
     zip_safe=False,

Reply via email to