From a4322301289a218048b434ea85a2dfe17cdfa3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Sat, 3 Sep 2016 13:50:40 +0200 Subject: [PATCH] Fixs annulations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix oublie de @staticmethod pour Settings.CANCEl_DURATION() - Mise en cache de Settings.CANCEL_DURATION - Fix sur cancel_operations : mauvais modèles et at --- kfet/models.py | 11 +++++++++-- kfet/views.py | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/kfet/models.py b/kfet/models.py index 69098ac9..07b56f2e 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -633,11 +633,17 @@ class Settings(models.Model): cache.set('OVERDRAFT_AMOUNT', overdraft_amount) return overdraft_amount + @staticmethod def CANCEL_DURATION(): + cancel_duration = cache.get('CANCEL_DURATION') + if cancel_duration: + return cancel_duration try: - return Settings.setting_inst("CANCEL_DURATION").value_duration + cancel_duration = Settings.setting_inst("CANCEL_DURATION").value_duration except Settings.DoesNotExist: - return timedelta() + cancel_duration = timedelta() + cache.set('CANCEL_DURATION', cancel_duration) + return cancel_duration @staticmethod def create_missing(): @@ -667,6 +673,7 @@ class Settings(models.Model): def empty_cache(): cache.delete_many([ 'SUBVENTION_COF','OVERDRAFT_DURATION', 'OVERDRAFT_AMOUNT', + 'CANCEL_DURATION', ]) class GenericTeamToken(models.Model): diff --git a/kfet/views.py b/kfet/views.py index f2f98f8f..f7f8728e 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -1075,10 +1075,10 @@ def kpsul_cancel_operations(request): # Note : si InventoryArticle est maj par .save(), stock_error # est recalculé automatiquement if ope.article and ope.article_nb: - last_stock = (ArticleInventory.objects + last_stock = (InventoryArticle.objects .select_related('inventory') .filter(article=ope.article) - .order_by('at') + .order_by('inventory__at') .last()) if not last_stock or last_stock.inventory.at < ope.group.at: to_articles_stocks[ope.article] += ope.article_nb