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

feat(export): formatter treats nil value in boolean custom field as false

as-op01665c6e4f5f
diff --git a/app/models/exports/formatters/custom_field.rb b/app/models/exports/formatters/custom_field.rb
index 228a2f43595..e0900c3baa6 100644
--- a/app/models/exports/formatters/custom_field.rb
+++ b/app/models/exports/formatters/custom_field.rb
@@ -18,10 +18,14 @@ module Exports
# Print the value meant for export.
#
# - For boolean values, don't use the Yes/No formatting for the UI
+ # treat nil as false
# - For long text values, output the plain value
def format_for_export(object, custom_field)
case custom_field.field_format
- when 'bool', 'text'
+ when 'bool'
+ value = object.typed_custom_value_for(custom_field)
+ value == nil ? false : value
+ when 'text'
object.typed_custom_value_for(custom_field)
else
object.formatted_custom_value_for(custom_field)