1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 18:08:21 +02:00

Open table and shelf life

This commit is contained in:
korenstin
2024-07-07 21:25:26 +02:00
parent 226a2a6357
commit 50a680eed2
5 changed files with 50 additions and 12 deletions

View File

@ -165,6 +165,12 @@ class TransformedFood(Food):
verbose_name=_('is active'),
)
# Without microbiological analyzes, the storage time is 3 days
shelf_life = models.DurationField(
verbose_name=_("shelf life"),
default=timedelta(days=3),
)
@transaction.atomic
def update_allergens(self):
# When allergens are changed, simply update the parents' allergens
@ -185,7 +191,7 @@ class TransformedFood(Food):
def update_expiry_date(self):
# When expiry_date is changed, simply update the parents' expiry_date
old_expiry_date = self.expiry_date
self.expiry_date = self.creation_date + timedelta(days=3)
self.expiry_date = self.creation_date + self.shelf_life
for ingredient in self.ingredient.iterator():
self.expiry_date = min(self.expiry_date, ingredient.expiry_date)