From cecb5ad88724695e4c50e4590b3d956d731c17cb Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Tue, 21 Jan 2014 13:45:39 +0100 Subject: [PATCH] Fixes missing journal notes on copy --- app/models/work_package.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/work_package.rb b/app/models/work_package.rb index ec2c2c2d7c..10a42114fe 100644 --- a/app/models/work_package.rb +++ b/app/models/work_package.rb @@ -669,7 +669,9 @@ class WorkPackage < ActiveRecord::Base end if work_package.save - unless options[:copy] + if options[:copy] + create_and_save_journal_note work_package, options[:journal_note] + else # Manually update project_id on related time entries TimeEntry.update_all("project_id = #{new_project.id}", {:work_package_id => id}) @@ -1009,4 +1011,11 @@ class WorkPackage < ActiveRecord::Base errors.messages[:attachments].first << " - #{invalid_attachment.errors.full_messages.first}" end end + + def create_and_save_journal_note(work_package, journal_note) + if work_package && journal_note + work_package.add_journal User.current, journal_note + work_package.save! + end + end end