From cf619b4184229d456b376e4c3885e0c8ce43077b Mon Sep 17 00:00:00 2001 From: Bradley Zylstra Date: Sat, 21 Mar 2026 07:46:03 -0400 Subject: [PATCH] [Bug] Import-records fix when importing from older InvenTree+Postgres version (#10862) * Fixed issue where importing data from older versions of InvenTree+Postgres would fail * Update tasks.py Changed .startswith to exact matching for users.userprofile. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update tasks.py Added validation checks to user primary key pairing dict. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Reverted tasks.py, disabled signals in user model when importing data --------- Co-authored-by: Oliver Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/backend/InvenTree/users/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/InvenTree/users/models.py b/src/backend/InvenTree/users/models.py index 3ead74515d..a9df02432f 100644 --- a/src/backend/InvenTree/users/models.py +++ b/src/backend/InvenTree/users/models.py @@ -600,6 +600,10 @@ class UserProfile(InvenTree.models.MetadataMixin): @receiver(post_save, sender=User) def create_or_update_user_profile(sender, instance, created, **kwargs): """Create or update user profile when user is saved.""" + # Disable profile creation if importing data from file + if isImportingData(): + return + if created: UserProfile.objects.create(user=instance) instance.profile.save() @@ -629,6 +633,10 @@ def validate_primary_group_on_delete(sender, instance, **kwargs): @receiver(m2m_changed, sender=User.groups.through) def validate_primary_group_on_group_change(sender, instance, action, **kwargs): """Validate primary_group on user profiles when a group is added or removed.""" + # Disable user profile validation if importing data from file + if isImportingData(): + return + if action in ['post_add', 'post_remove']: profile = instance.profile if profile.primary_group and profile.primary_group not in instance.groups.all():