[FIX] product: price computation with dated pricelist rules and tz

Take account of the user timezone to compute the price for
pricelist rules with start / end date.

Before this revision, the date used to compare to
the dated pricelist rule is always the date of today
in UTC.

For instance:
- If a user is in timezone UTC +12
- The 10% discount on the pricelist starts on December 19
- It's currently December 18 13:00

The user did not have the discount,
because it was consdiered December 18,
while the user was already in December 19.

With this revision, we take account of the context
and its timezone to compute the date of today
and return the correct price according to the
dated start and end datetime.

opw-785203
This commit is contained in:
Denis Ledoux
2017-12-18 18:23:22 +01:00
parent b1b13dbeed
commit f3da958fa1
+1 -1
View File
@@ -106,7 +106,7 @@ class Pricelist(models.Model):
"""
self.ensure_one()
if not date:
date = self._context.get('date') or fields.Date.today()
date = self._context.get('date') or fields.Date.context_today(self)
if not uom_id and self._context.get('uom'):
uom_id = self._context['uom']
if uom_id: