Fixs annulations
- Fix oublie de @staticmethod pour Settings.CANCEl_DURATION() - Mise en cache de Settings.CANCEL_DURATION - Fix sur cancel_operations : mauvais modèles et at
This commit is contained in:
parent
d12dfe2f56
commit
a432230128
2 changed files with 11 additions and 4 deletions
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue