diff options
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 7 | 
1 files changed, 5 insertions, 2 deletions
| diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 696f4d685..6e74f2c44 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -429,6 +429,7 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem,          if self.start_date and not self.year:              self.year = self.start_date.year          # manage parcel association +        """          if FILES_AVAILABLE and self.associated_file:              for parcel in self.associated_file.parcels.exclude(                                          operation=self).all(): @@ -445,7 +446,7 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem,                      parcel.merge(parcels[keys])                  else:                      parcels[keys] = parcel - +        """          return super(Operation, self).save(*args, **kwargs)  m2m_changed.connect(cached_label_changed, sender=Operation.towns.through) @@ -792,9 +793,11 @@ def parcel_post_save(sender, **kwargs):          parcel.external_id = (parcel.section or "") + (parcel.parcel_number or "")          parcel.save()          return -    if parcel.operation and parcel.town not in list(parcel.operation.towns.all()): +    if parcel.operation and parcel.operation.pk and \ +       parcel.town not in list(parcel.operation.towns.all()):          parcel.operation.towns.add(parcel.town)      if FILES_AVAILABLE and parcel.associated_file and \ +       parcel.associated_file.pk and \         parcel.town not in list(parcel.associated_file.towns.all()):          parcel.associated_file.towns.add(parcel.town)      if not FILES_AVAILABLE: | 
