OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/lib/open_project/costs/patches/issue_observer.rb

25 lines
687 B

require_dependency 'issue'
class CostsIssueObserver < ActiveRecord::Observer
unloadable
observe :issue
def after_update(issue)
if issue.project_id_changed?
# TODO: This only works with the global cost_rates
CostEntry.update_all({:project_id => issue.project_id}, {:issue_id => issue.id})
end
end
def before_update(issue)
# FIXME: remove this method once controller_issues_move_before_save is in 0.9-stable
if issue.project_id_changed? && issue.cost_object_id && !issue.project.cost_object_ids.include?(issue.cost_object_id)
issue.cost_object = nil
end
# true
end
end
ActiveRecord::Base.observers.push :costs_issue_observer