From bb2c6f607610442d6be8de893ff15ff715ceb0d7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 11 Apr 2016 17:11:59 +0000 Subject: Fixed that subtasks lose their custom fields when copying an issue to a different project (#22342). git-svn-id: http://svn.redmine.org/redmine/trunk@15318 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/models') diff --git a/app/models/issue.rb b/app/models/issue.rb index 5bf845d84..b433da30b 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -302,16 +302,19 @@ class Issue < ActiveRecord::Base # * or if the status was not part of the new tracker statuses # * or the status was nil def tracker=(tracker) - if tracker != self.tracker + tracker_was = self.tracker + if tracker != tracker_was if status == default_status self.status = nil elsif status && tracker && !tracker.issue_status_ids.include?(status.id) self.status = nil end - @custom_field_values = nil @workflow_rule_by_attribute = nil end association(:tracker).writer(tracker) + if tracker != tracker_was + reassign_custom_field_values + end self.status ||= default_status self.tracker end @@ -355,7 +358,7 @@ class Issue < ActiveRecord::Base unless valid_parent_project? self.parent_issue_id = nil end - @custom_field_values = nil + reassign_custom_field_values @workflow_rule_by_attribute = nil end # Set fixed_version to the project default version if it's valid -- cgit v1.2.3