[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) <len@odoo.com>
This commit is contained in:
Nans Lefebvre
2019-09-19 14:05:23 +00:00
committed by fw-bot
parent eb2885bc79
commit c92fb90e7b
+3 -3
View File
@@ -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: