diff options
author | Go MAEDA <maeda@farend.jp> | 2023-02-16 00:31:29 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2023-02-16 00:31:29 +0000 |
commit | a3ca8ba677991c58140a8cfd6590ae15352cee5d (patch) | |
tree | dec42c9368dd4bbd8049b1dcc5075c18cbf247cc /app | |
parent | dc50caf1bed6f76ac9fdc5248c8c8ed24d36fa59 (diff) | |
download | redmine-a3ca8ba677991c58140a8cfd6590ae15352cee5d.tar.gz redmine-a3ca8ba677991c58140a8cfd6590ae15352cee5d.zip |
Time Entry Import fails to import custom fields with "User" format (#38254).
Patch by Jens Krämer.
git-svn-id: https://svn.redmine.org/redmine/trunk@22112 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/time_entry_import.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/time_entry_import.rb b/app/models/time_entry_import.rb index 1659e6efa..a6dfee53c 100644 --- a/app/models/time_entry_import.rb +++ b/app/models/time_entry_import.rb @@ -116,8 +116,10 @@ class TimeEntryImport < Import if issue_id = row_value(row, 'issue_id').presence attributes[:issue_id] = issue_id + object.project = issue_project(issue_id) else attributes[:project_id] = project.id + object.project = project end attributes['custom_field_values'] = object.custom_field_values.inject({}) do |h, v| @@ -137,4 +139,10 @@ class TimeEntryImport < Import object.send(:safe_attributes=, attributes, user) object end + + def issue_project(issue_id) + if issue_project_id = Issue.where(id: issue_id).limit(1).pick(:project_id) + (@projects_cache ||= {})[issue_project_id] ||= allowed_target_projects.find_by_id(issue_project_id) + end + end end |