New custom fields of existing issues are not initialized with their default value (#21074).

git-svn-id: http://svn.redmine.org/redmine/trunk@14773 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2015-10-31 09:17:29 +00:00
parent 9a3b8e0b1e
commit e6112a9710
4 changed files with 20 additions and 10 deletions

View File

@@ -92,12 +92,12 @@ module Redmine
if field.multiple?
values = custom_values.select { |v| v.custom_field == field }
if values.empty?
values << custom_values.build(:customized => self, :custom_field => field, :value => nil)
values << custom_values.build(:customized => self, :custom_field => field)
end
x.value = values.map(&:value)
else
cv = custom_values.detect { |v| v.custom_field == field }
cv ||= custom_values.build(:customized => self, :custom_field => field, :value => nil)
cv ||= custom_values.build(:customized => self, :custom_field => field)
x.value = cv.value
end
x.value_was = x.value.dup if x.value