Sergi Almacellas Abellana pushed to branch branch/default at Tryton / Tryton


Commits:
59e0d2ef by Sergi Almacellas Abellana at 2023-02-15T14:26:59+01:00
Catch Overflow error when converting datetime to company timestamp

Closes #11999
- - - - -
8d4d6b81 by Sergi Almacellas Abellana at 2023-02-22T08:59:58+01:00
Set timezone in product cost history scenario
- - - - -


2 changed files:

- modules/product_cost_history/product.py
- modules/product_cost_history/tests/scenario_product_cost_history.rst


Changes:

=====================================
modules/product_cost_history/product.py
=====================================
@@ -42,8 +42,12 @@
                 company = Company(company)
                 if company.timezone:
                     timezone = tz.ZoneInfo(company.timezone)
-                    datetime = (
-                        datetime.replace(tzinfo=tz.UTC).astimezone(timezone))
+                    try:
+                        datetime = (
+                            datetime.replace(tzinfo=tz.UTC).astimezone(
+                                timezone))
+                    except OverflowError:
+                        pass
             cost_price = self.get_cost_price_at(datetime.date(), **pattern)
             if cost_price is not None:
                 return cost_price


=====================================
modules/product_cost_history/tests/scenario_product_cost_history.rst
=====================================
@@ -22,6 +22,8 @@
 
     >>> _ = create_company()
     >>> company = get_company()
+    >>> company.timezone = 'Europe/Madrid'
+    >>> company.save()
 
 Create product::
 



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/compare/65e7ccc438fb89df0b41b70c360c8788ee799af9...8d4d6b810c72282e99d4c58bb7f4f4ef12d8830b

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/compare/65e7ccc438fb89df0b41b70c360c8788ee799af9...8d4d6b810c72282e99d4c58bb7f4f4ef12d8830b
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to