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

Reference work package records instead of hierarchy

Aaron Contreras2a2900e60db8
diff --git a/app/controllers/work_packages/moves_controller.rb b/app/controllers/work_packages/moves_controller.rb
index 0ffb7779eb9..a9bbe6cd8e9 100644
--- a/app/controllers/work_packages/moves_controller.rb
+++ b/app/controllers/work_packages/moves_controller.rb
@@ -127,8 +127,10 @@ class WorkPackages::MovesController < ApplicationController
if @target_project == @project
false
elsif @target_type.nil?
- work_packages_and_descendants = WorkPackageHierarchy.where(ancestor_id: @work_packages.select(:id))
- Type.where(id: work_packages_and_descendants.select(:id))
+ hierarchies = WorkPackageHierarchy
+ .includes(:ancestor)
+ .where(ancestor_id: @work_packages.select(:id))
+ Type.where(id: hierarchies.map { _1.ancestor.type_id })
.select("distinct id")
.pluck(:id)
.difference(@types.pluck(:id))