Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

reset mapping and fields associations after insert_all/delete_all in bulk update

Ivan Kuchinc5ea5d0aa3ef
diff --git a/app/services/project_custom_field_project_mappings/bulk_update_service.rb b/app/services/project_custom_field_project_mappings/bulk_update_service.rb
index 90a8c41bb13..c90dd590171 100644
--- a/app/services/project_custom_field_project_mappings/bulk_update_service.rb
+++ b/app/services/project_custom_field_project_mappings/bulk_update_service.rb
@@ -91,6 +91,8 @@ module ProjectCustomFieldProjectMappings
@project.project_custom_field_project_mappings
.where(custom_field_id: custom_field_ids)
.delete_all
+
+ reset_associations
end
def existing_mappings(custom_field_ids)
@@ -105,6 +107,13 @@ module ProjectCustomFieldProjectMappings
custom_field_ids.map { |id| { custom_field_id: id } },
unique_by: %i[project_id custom_field_id]
)
+
+ reset_associations
+ end
+
+ def reset_associations
+ @project.project_custom_field_project_mappings.reset
+ @project.project_custom_fields.reset
end
end
end