From 85b9f3abfd1d931193df455474f6686037f61578 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Thu, 5 Sep 2019 08:54:23 +0000 Subject: [PATCH] [FIX] product: pricelists with temporary discounts Create a pricelist with a temporary discount on some product only for today. Go to the shop. The discount is applied on the product. Add the product to the cart. Go to the cart page (review order): the price does not use the discount. Because the query getting the pricelist item is some handwritten SQL, it only works for dates, and not e.g. in the case of datetimes. So the pricelist item encoding the discount is not retrieved, and thus not used. It turns out e.g. in _website_product_id_change it gives a datetime in context, explaining why sometimes the discount is applied, and sometimes not. We use fields.Date.to_date as it should work on all date formats we shall pass. Co-written with @sbbaro opw 2054881 closes odoo/odoo#36453 Signed-off-by: Nans Lefebvre (len) --- addons/product/models/product_pricelist.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/product/models/product_pricelist.py b/addons/product/models/product_pricelist.py index dd023de06ce..91462e22e3f 100644 --- a/addons/product/models/product_pricelist.py +++ b/addons/product/models/product_pricelist.py @@ -109,6 +109,7 @@ 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) if not uom_id and self._context.get('uom'): uom_id = self._context['uom'] if uom_id: