From 5439cfcc403fbc1704356829228481594bcbdd4a Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Sun, 18 Feb 2024 13:54:23 -0500 Subject: [PATCH] [FIX] point_of_sale: Convert shipping_date to datetime correctly before creating procurement. Since shipping_date is a Date but date_planned is a datetime, before this commit, the date_planned in picking was one day less. complementary to https://github.com/odoo/odoo/commit/fe9e230b500af316e6f80af453a4073d9dff24b7 closes odoo/odoo#154533 Signed-off-by: Adrien Guilliams (adgu) --- addons/point_of_sale/models/pos_order.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 1474af3fe4e..94e75303eff 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -1418,7 +1418,13 @@ class PosOrderLine(models.Model): self.ensure_one() # Use the delivery date if there is else use date_order and lead time if self.order_id.shipping_date: - date_deadline = self.order_id.shipping_date + # get timezone from user + # and convert to UTC to avoid any timezone issue + # because shipping_date is date and date_planned is datetime + from_zone = pytz.timezone(self._context.get('tz') or self.env.user.tz or 'UTC') + shipping_date = fields.Datetime.to_datetime(self.order_id.shipping_date) + shipping_date = from_zone.localize(shipping_date) + date_deadline = shipping_date.astimezone(pytz.UTC).replace(tzinfo=None) else: date_deadline = self.order_id.date_order