diff options
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r-- | archaeological_warehouse/models.py | 16 |
1 files changed, 16 insertions, 0 deletions
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() |