On ne supprime pas les dupliqués même s'ils sont dans le même import

This commit is contained in:
Jean-Marie Favreau 2025-03-02 16:30:02 +01:00
parent 583679b546
commit 56ae9a06e9

View File

@ -1481,12 +1481,15 @@ class Event(models.Model):
# check if we need to clean the other_versions # check if we need to clean the other_versions
if ( if (
not clone not clone
and not "noclean_other_versions" in kwargs
and self.pk and self.pk
and self.other_versions is not None and self.other_versions is not None
and self.other_versions.nb_duplicated() == 1 and self.other_versions.nb_duplicated() == 1
): ):
self.other_versions.delete() self.other_versions.delete()
self.other_versions = None self.other_versions = None
if "noclean_other_versions" in kwargs:
del kwargs["noclean_other_versions"]
# first save the current object # first save the current object
super().save(*args, **kwargs) super().save(*args, **kwargs)
@ -2042,7 +2045,7 @@ class Event(models.Model):
or new_image or new_image
): ):
same_imported.download_image() same_imported.download_image()
same_imported.save(update_fields=["local_image"]) same_imported.save(update_fields=["local_image"], noclean_other_versions=True)
to_update.append(same_imported) to_update.append(same_imported)
else: else: