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

Use previously_new_record? in the available_custom_fields of the aac project patch.

Dombi Attilad6b5030eb147
diff --git a/app/models/projects/acts_as_customizable_patches.rb b/app/models/projects/acts_as_customizable_patches.rb
index 0006d173f65..d7dc07070d3 100644
--- a/app/models/projects/acts_as_customizable_patches.rb
+++ b/app/models/projects/acts_as_customizable_patches.rb
@@ -155,7 +155,7 @@ module Projects::ActsAsCustomizablePatches
#
# additionally we provide the `global` parameter to allow querying the available custom fields on a global level
# when we have explicit control over the call of `available_custom_fields`
- unless new_record? || _query_available_custom_fields_on_global_level
+ unless global_custom_fields?
custom_fields = custom_fields
.where(id: project_custom_field_project_mappings.select(:custom_field_id))
.or(ProjectCustomField.required)
@@ -164,6 +164,10 @@ module Projects::ActsAsCustomizablePatches
custom_fields
end
+ def global_custom_fields?
+ new_record? || previously_new_record? || _query_available_custom_fields_on_global_level
+ end
+
def all_available_custom_fields
with_all_available_custom_fields { available_custom_fields }
end
@@ -172,10 +176,7 @@ module Projects::ActsAsCustomizablePatches
# that are factored in the calculation of the available_custom_fields method should be included
# in the custom_values_cache_key too.
def custom_values_cache_key
- [
- _query_available_custom_fields_on_global_level || new_record?,
- _limit_custom_fields_validation_to_section_id
- ]
+ [global_custom_fields?, _limit_custom_fields_validation_to_section_id]
end
# we need to query the available custom fields on a global level when updating custom field values