From 436996445e9254459f4f1726385e935a42eac6dc Mon Sep 17 00:00:00 2001 From: Johan De Taeye Date: Mon, 26 Feb 2024 14:20:32 +0100 Subject: [PATCH 1/2] inbound.py: make all datetime parsing aware of the timezone --- frepple/controllers/inbound.py | 59 ++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 10 deletions(-) diff --git a/frepple/controllers/inbound.py b/frepple/controllers/inbound.py index bb6afb94..a244a44d 100644 --- a/frepple/controllers/inbound.py +++ b/frepple/controllers/inbound.py @@ -174,13 +174,31 @@ def run(self): st = elem.get("start") if st: try: - wo["start"] = datetime.strptime(st, "%Y-%m-%d %H:%M:%S") + wo["start"] = ( + self.timezone.localize( + datetime.strptime( + st, + "%Y-%m-%d %H:%M:%S", + ) + ) + .astimezone(UTC) + .replace(tzinfo=None) + ) except Exception: pass nd = elem.get("end") if st: try: - wo["end"] = datetime.strptime(nd, "%Y-%m-%d %H:%M:%S") + wo["end"] = ( + self.timezone.localize( + datetime.strptime( + nd, + "%Y-%m-%d %H:%M:%S", + ) + ) + .astimezone(UTC) + .replace(tzinfo=None) + ) except Exception: pass wo_data.append(wo) @@ -209,13 +227,27 @@ def run(self): quantity = float(elem.get("quantity")) date_planned = elem.get("end") if date_planned: - date_planned = datetime.strptime( - date_planned, "%Y-%m-%d %H:%M:%S" + date_planned = ( + self.timezone.localize( + datetime.strptime( + date_planned, + "%Y-%m-%d %H:%M:%S", + ) + ) + .astimezone(UTC) + .replace(tzinfo=None) ) date_ordered = elem.get("start") if date_ordered: - date_ordered = datetime.strptime( - date_ordered, "%Y-%m-%d %H:%M:%S" + date_ordered = ( + self.timezone.localize( + datetime.strptime( + date_ordered, + "%Y-%m-%d %H:%M:%S", + ) + ) + .astimezone(UTC) + .replace(tzinfo=None) ) # Is that an update of an existing PO ? @@ -390,12 +422,19 @@ def run(self): continue if date_shipping: - date_shipping = datetime.strptime( - date_shipping, "%Y-%m-%d %H:%M:%S" + date_shipping = ( + self.timezone.localize( + datetime.strptime( + date_shipping, + "%Y-%m-%d %H:%M:%S", + ) + ) + .astimezone(UTC) + .replace(tzinfo=None) ) else: - date_shipping = datetime.strptime( - datetime.now(), "%Y-%m-%d %H:%M:%S" + date_shipping = ( + datetime.now().astimezone(UTC).replace(tzinfo=None) ) if not hasattr(self, "stock_picking_dict"): self.stock_picking_dict = {} From b3aef2d9bb43f21f556c1b03949cbe34a6bbc281 Mon Sep 17 00:00:00 2001 From: Johan De Taeye Date: Mon, 26 Feb 2024 17:03:10 +0100 Subject: [PATCH 2/2] merge issues - methods don't exist in 16 --- frepple/controllers/inbound.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/frepple/controllers/inbound.py b/frepple/controllers/inbound.py index a244a44d..fe303749 100644 --- a/frepple/controllers/inbound.py +++ b/frepple/controllers/inbound.py @@ -608,8 +608,6 @@ def run(self): # Remember odoo name for the MO reference passed by frepple. # This mapping is later used when importing WO. mo_references[elem.get("reference")] = mo - mo._onchange_workorder_ids() - mo._onchange_move_raw() mo._create_update_move_finished() # mo.action_confirm() # confirm MO # mo._plan_workorders() # plan MO