diff --git a/app/models/custom_actions/actions/custom_field.rb b/app/models/custom_actions/actions/custom_field.rb index c1b0a82eba89..374b3406218a 100644 --- a/app/models/custom_actions/actions/custom_field.rb +++ b/app/models/custom_actions/actions/custom_field.rb @@ -49,7 +49,7 @@ def apply(work_package) def self.all WorkPackageCustomField - .order(:name) + .usable_as_custom_action .map do |cf| create_subclass(cf) end diff --git a/app/models/work_package_custom_field.rb b/app/models/work_package_custom_field.rb index 1b1a68fe5bc8..0c1776abe2ad 100644 --- a/app/models/work_package_custom_field.rb +++ b/app/models/work_package_custom_field.rb @@ -49,6 +49,11 @@ class WorkPackageCustomField < CustomField end } + scope :usable_as_custom_action, -> { + where.not(field_format: %w[hierarchy]) + order(:name) + } + def self.summable where(field_format: %w[int float]) end diff --git a/spec/models/custom_actions/actions/custom_field_spec.rb b/spec/models/custom_actions/actions/custom_field_spec.rb index e8cea930e9ab..05c68c594384 100644 --- a/spec/models/custom_actions/actions/custom_field_spec.rb +++ b/spec/models/custom_actions/actions/custom_field_spec.rb @@ -98,7 +98,7 @@ describe ".all" do before do allow(WorkPackageCustomField) - .to receive(:order) + .to receive(:usable_as_custom_action) .and_return(custom_fields) end