diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-09-20 12:50:06 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-09-20 12:50:06 +0000 |
commit | a28bf20c4ca2c422aceed602c398adf3aa85f92c (patch) | |
tree | 164efc4e672ab1b7dc7249a78b63bbb91696ec54 /app/models | |
parent | eb57fa4847dab2bdc0026ef86ad6ade0f8a5b1cf (diff) | |
download | redmine-a28bf20c4ca2c422aceed602c398adf3aa85f92c.tar.gz redmine-a28bf20c4ca2c422aceed602c398adf3aa85f92c.zip |
Project copy does not update custom field of version type values (#20361).
git-svn-id: http://svn.redmine.org/redmine/trunk@14615 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 2138773cf..8cd2bf993 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -899,6 +899,22 @@ class Project < ActiveRecord::Base if issue.fixed_version && issue.fixed_version.project == project new_issue.fixed_version = self.versions.detect {|v| v.name == issue.fixed_version.name} end + # Reassign version custom field values + new_issue.custom_field_values.each do |custom_value| + if custom_value.custom_field.field_format == 'version' && custom_value.value.present? + versions = Version.where(:id => custom_value.value).to_a + new_value = versions.map do |version| + if version.project == project + self.versions.detect {|v| v.name == version.name}.try(:id) + else + version.id + end + end + new_value.compact! + new_value = new_value.first unless custom_value.custom_field.multiple? + custom_value.value = new_value + end + end # Reassign the category by name, since names are unique per project if issue.category new_issue.category = self.issue_categories.detect {|c| c.name == issue.category.name} |