From c92fb90e7b118cb7c82fbc6feaa2d72731713804 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Mon, 16 Sep 2019 13:43:31 +0000 Subject: [PATCH] [FIX] product: always use UTC to compare pricelist dates In case where no argument is given to _compute_price_rule, it would default to context_today(). This gives "today" in function of the context, depending on the user timezone. In contrast, an explicitly given date would always be UTC. Furthermore, on the webshop an unlogged user would get the Public User timezone, and once logged would get its portal user's timezone. To make everything coherent, we always use UTC. opw 2054881 closes odoo/odoo#37154 X-original-commit: 35d4a8ccce8f3a34701d231e17a324cbbf5abfab Signed-off-by: Nans Lefebvre (len) --- addons/product/models/product_pricelist.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/product/models/product_pricelist.py b/addons/product/models/product_pricelist.py index fab35f27692..bd9b97f20e3 100644 --- a/addons/product/models/product_pricelist.py +++ b/addons/product/models/product_pricelist.py @@ -103,7 +103,7 @@ class Pricelist(models.Model): """ Low-level method - Mono pricelist, multi products Returns: dict{product_id: (price, suitable_rule) for the given pricelist} - If date in context: Date of the pricelist (%Y-%m-%d) + Date in context can be a date, datetime, ... :param products_qty_partner: list of typles products, quantity, partner :param datetime date: validity date @@ -111,8 +111,8 @@ class Pricelist(models.Model): """ self.ensure_one() if not date: - date = self._context.get('date') or fields.Date.context_today(self) - date = fields.Date.to_date(date) # handwritten query below does not work with non-dates (e.g. datetimes) + date = self._context.get('date') or fields.Date.today() + date = fields.Date.to_date(date) # boundary conditions differ if we have a datetime if not uom_id and self._context.get('uom'): uom_id = self._context['uom'] if uom_id: