From 08fec3a29e2aac2cb71a26e09a56789508bd8e30 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Wed, 15 Feb 2023 14:26:59 +0100 Subject: [PATCH] Catch Overflow error when converting datetime to company timestamp Closes #11999 --- modules/product_cost_history/product.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/product_cost_history/product.py b/modules/product_cost_history/product.py index 251669c3e8..cbde496f10 100644 --- a/modules/product_cost_history/product.py +++ b/modules/product_cost_history/product.py @@ -42,8 +42,12 @@ class Product(metaclass=PoolMeta): 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