Quand un article n'a pas de conso, il a été créé il y a 1s
This commit is contained in:
Ludovic Stephan 2020-03-09 16:32:38 +01:00
parent 97cb9d1f3b
commit f10d6d1a71

View file

@ -2,6 +2,7 @@ import ast
import heapq import heapq
import statistics import statistics
from collections import defaultdict from collections import defaultdict
from datetime import timedelta
from decimal import Decimal from decimal import Decimal
from typing import List from typing import List
from urllib.parse import urlencode from urllib.parse import urlencode
@ -2523,9 +2524,12 @@ class ArticleStatSalesList(SingleResumeStat):
first_conso = ( first_conso = (
Operation.objects.filter(article=self.object) Operation.objects.filter(article=self.object)
.order_by("group__at") .order_by("group__at")
.values_list("group__at", flat=True)
.first() .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 = [ scales_def = [
("Tout le temps", MonthScale, {"last": True, "begin": first_conso}, False), ("Tout le temps", MonthScale, {"last": True, "begin": first_conso}, False),
("1 an", MonthScale, {"last": True, "n_steps": 12}, False), ("1 an", MonthScale, {"last": True, "n_steps": 12}, False),