diff options
| -rw-r--r-- | archaeological_finds/models_finds.py | 14 | ||||
| -rw-r--r-- | archaeological_warehouse/tests.py | 11 | ||||
| -rw-r--r-- | changelog/en/changelog_2022-06-15.md | 3 | ||||
| -rw-r--r-- | changelog/fr/changelog_2023-01-25.md | 3 | 
4 files changed, 26 insertions, 5 deletions
| diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 4b976a730..5eb204949 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -3241,7 +3241,7 @@ class Find(              old_container = self.__class__.objects.filter(pk=self.pk).values_list(                  "container_id", flat=True              )[0] -        super(Find, self).save(*args, **kwargs) +        super().save(*args, **kwargs)          self.skip_history_when_saving = True          if self.container_ref and not self.container: @@ -3249,12 +3249,16 @@ class Find(          if self.container and self.container._calculate_weight():              self.container.save() -        elif not self.container and old_container: +        if (self.container and self.container.pk != old_container) or ( +                not self.container and old_container):              # force recalculation of weight when a find is removed              Container = apps.get_model("archaeological_warehouse.Container") -            old_container = Container.objects.get(pk=old_container) -            if old_container._calculate_weight(): -                old_container.save() +            try: +                old_container = Container.objects.get(pk=old_container) +                if old_container._calculate_weight(): +                    old_container.save() +            except Container.DoesNotExist: +                pass          updated = self.update_external_id(save=False)          if updated: diff --git a/archaeological_warehouse/tests.py b/archaeological_warehouse/tests.py index 54432f9a5..ebea75217 100644 --- a/archaeological_warehouse/tests.py +++ b/archaeological_warehouse/tests.py @@ -1177,11 +1177,22 @@ class ContainerTest(FindInit, TestCase):          self.assertEqual(container_1.calculated_weight, 1500)          self.assertEqual(container_1.cached_weight, 1500) +        container_2 = models.Container.objects.create( +            reference="Test 2", location=self.main_warehouse, container_type=ct +        ) +        find2.container = container_2 +        find2.save() +        container_1 = models.Container.objects.get(pk=container_1.pk) +        self.assertEqual(container_1.calculated_weight, 800) +        self.assertEqual(container_1.cached_weight, 800) +          profile, created = IshtarSiteProfile.objects.get_or_create(              slug="default", active=True          )          profile.calculate_weight_on_full = True          profile.save() +        find2.container = container_1 +        find2.save()          container_1.save()          container_1 = models.Container.objects.get(pk=container_1.pk) diff --git a/changelog/en/changelog_2022-06-15.md b/changelog/en/changelog_2022-06-15.md index 8184abfb0..8d87e79c8 100644 --- a/changelog/en/changelog_2022-06-15.md +++ b/changelog/en/changelog_2022-06-15.md @@ -1,6 +1,9 @@  v4.0.46 - 2023-  -------------------- + +🐛 JS: fix UnitWidget (inappropriate l10n) +  ### Technical ###  - JS: fix UnitWidget (inappropriate l10n) diff --git a/changelog/fr/changelog_2023-01-25.md b/changelog/fr/changelog_2023-01-25.md index ec3f0aec7..3f820557e 100644 --- a/changelog/fr/changelog_2023-01-25.md +++ b/changelog/fr/changelog_2023-01-25.md @@ -1,6 +1,9 @@  v4.0.46 - 2023-  -------------------- +### Corrections de dysfonctionnements ### +- recalcul du poids d'un contenant lorsque du mobilier en est retiré (refs #5470) +  ### Technique ###  - JS : correction UnitWidget (localisation inappropriée) | 
