From 66232651ef2a2c1f331dc381a8f86f24a279ba85 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 9 Sep 2024 14:45:17 +0200 Subject: ✨ find container history: manage first packaging info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_warehouse/models.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'archaeological_warehouse/models.py') diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index d501eab1f..8bcc2bd65 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -1946,6 +1946,21 @@ class Container( ] return actions + def update_find_location(self): + full_location = self.generate_full_location() + if not full_location: + return + for find in self.finds.all(): + updated = find.update_current_full_location(full_location) + if updated: + find.skip_history_when_saving = True + find.save() + for find in self.finds_ref.all(): + updated = find.update_ref_full_location(full_location) + if updated: + find.skip_history_when_saving = True + find.save() + def pre_save(self): if self.parent == self: self.parent = None @@ -1992,6 +2007,7 @@ class Container( logger.debug(f"[ishtar] archaeological_warehouse.models.Container.save - {self.pk} - {self.cached_label}") self.pre_save() super().save(*args, **kwargs) + self.update_find_location() self._change_child_location(self) updated = False updated += self._prevent_parent_infinite_loop() -- cgit v1.2.3