diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-05-18 17:27:32 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:20 +0100 |
commit | 9ec07a773741f7bb5da85aba04ca159b429f7b81 (patch) | |
tree | e0435fcaff5fdfb3b5cb53ee4b3754b60864bea9 /archaeological_warehouse/management/commands/migrate_to_new_container_management.py | |
parent | 3b8c2e3bff7c1ba8931f0c6b4c5ec94b95f7a2fe (diff) | |
download | Ishtar-9ec07a773741f7bb5da85aba04ca159b429f7b81.tar.bz2 Ishtar-9ec07a773741f7bb5da85aba04ca159b429f7b81.zip |
Migrate to new container management: fix existing duplicates - fix on delete view
Diffstat (limited to 'archaeological_warehouse/management/commands/migrate_to_new_container_management.py')
-rw-r--r-- | archaeological_warehouse/management/commands/migrate_to_new_container_management.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/archaeological_warehouse/management/commands/migrate_to_new_container_management.py b/archaeological_warehouse/management/commands/migrate_to_new_container_management.py index d8f701793..44895ce69 100644 --- a/archaeological_warehouse/management/commands/migrate_to_new_container_management.py +++ b/archaeological_warehouse/management/commands/migrate_to_new_container_management.py @@ -87,8 +87,17 @@ class Command(BaseCommand): ref].append(division.reference.strip()) parent = new_container if parent: - container.parent = parent - container.save() + q = models.Container.objects.filter( + location=container.location, + container_type=container.container_type, + parent=parent, + reference=container.reference).exclude(pk=container.pk) + if q.count(): + other = q.all()[0] + other.merge(container) + else: + container.parent = parent + container.save() data.append((container.id, str(container.responsible), container.reference, cached_division, container._generate_cached_division())) |