From f10d6d1a71d6075ebeddf77b8777a727a9a5a2c0 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 9 Mar 2020 16:32:38 +0100 Subject: [PATCH] Bugfix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quand un article n'a pas de conso, il a été créé il y a 1s --- kfet/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kfet/views.py b/kfet/views.py index a0e3115c..b6c49f72 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -2,6 +2,7 @@ import ast import heapq import statistics from collections import defaultdict +from datetime import timedelta from decimal import Decimal from typing import List from urllib.parse import urlencode @@ -2523,9 +2524,12 @@ class ArticleStatSalesList(SingleResumeStat): first_conso = ( Operation.objects.filter(article=self.object) .order_by("group__at") + .values_list("group__at", flat=True) .first() - .group.at ) + if first_conso is None: + # On le crée dans le passé au cas où + first_conso = timezone.now() - timedelta(seconds=1) scales_def = [ ("Tout le temps", MonthScale, {"last": True, "begin": first_conso}, False), ("1 an", MonthScale, {"last": True, "n_steps": 12}, False),