diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-10-09 06:43:03 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-10-09 06:43:03 +0000 |
commit | 3ea387379d3b60d175a19534bf497c30ff1bba9c (patch) | |
tree | 0bfe5991382c384f6026324affc2584f138407c1 /app | |
parent | 5cec71b64c7d0e91ee9107ae1a15214419ec5539 (diff) | |
download | redmine-3ea387379d3b60d175a19534bf497c30ff1bba9c.tar.gz redmine-3ea387379d3b60d175a19534bf497c30ff1bba9c.zip |
Merged r14618 (#20360).
git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@14653 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index f4d458726..0494a8298 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -526,11 +526,17 @@ class Project < ActiveRecord::Base # Returns a scope of all custom fields enabled for project issues # (explicitly associated custom fields and custom fields enabled for all projects) def all_issue_custom_fields - @all_issue_custom_fields ||= IssueCustomField. - sorted. - where("is_for_all = ? OR id IN (SELECT DISTINCT cfp.custom_field_id" + - " FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} cfp" + - " WHERE cfp.project_id = ?)", true, id) + if new_record? + @all_issue_custom_fields ||= IssueCustomField. + sorted. + where("is_for_all = ? OR id IN (?)", true, issue_custom_field_ids) + else + @all_issue_custom_fields ||= IssueCustomField. + sorted. + where("is_for_all = ? OR id IN (SELECT DISTINCT cfp.custom_field_id" + + " FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} cfp" + + " WHERE cfp.project_id = ?)", true, id) + end end # Returns an array of all custom fields enabled for project time entries |