From 30e374e52f7bdf336d1f9076e4e343d596aa9ebc Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 21 Mar 2025 14:44:50 +0100 Subject: ✨ warehouse: auto associate town of the organization if not town is provided (refs #6192) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_warehouse/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'archaeological_warehouse/models.py') diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 121e2bbb9..943d8e49c 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -667,8 +667,12 @@ class Warehouse( return False def save(self, *args, **kwargs): + if not self.precise_town_id and self.organization \ + and self.organization.precise_town_id: + self.precise_town_id = self.organization.precise_town_id + self.update_search_vector() - super(Warehouse, self).save(*args, **kwargs) + super().save(*args, **kwargs) updated = False if not self.slug and self.name: -- cgit v1.2.3