mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-11 23:59:31 -06:00
Trash versions when deleting head docs
This commit is contained in:
@@ -436,6 +436,12 @@ class Document(SoftDeleteModel, ModelWithOwner):
|
||||
tags_to_add = self.tags.model.objects.filter(id__in=tag_ids)
|
||||
self.tags.add(*tags_to_add)
|
||||
|
||||
def delete(self, using=None, *, keep_parents=False):
|
||||
# If deleting a head document, move all versions to trash as well.
|
||||
if self.head_version_id is None:
|
||||
Document.objects.filter(head_version=self).delete()
|
||||
return super().delete(using=using, keep_parents=keep_parents)
|
||||
|
||||
|
||||
class SavedView(ModelWithOwner):
|
||||
class DisplayMode(models.TextChoices):
|
||||
|
||||
Reference in New Issue
Block a user