diff --git a/awx/main/tasks.py b/awx/main/tasks.py index aca866ccd0..cc38360a5d 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -548,6 +548,8 @@ def delete_inventory(self, inventory_id, user_id): with ignore_inventory_computed_fields(), ignore_inventory_group_removal(), impersonate(user): try: i = Inventory.objects.get(id=inventory_id) + for host in i.hosts.iterator(): + host.job_events_as_primary_host.update(host=None) i.delete() emit_channel_notification( 'inventories-status_changed',