diff --git a/lib/open_project/costs/engine.rb b/lib/open_project/costs/engine.rb index 0446ce0211..0cbb913c57 100644 --- a/lib/open_project/costs/engine.rb +++ b/lib/open_project/costs/engine.rb @@ -121,15 +121,17 @@ module OpenProject::Costs end send(:define_method, :spent_hours) do - attributes_helper = OpenProject::Costs::AttributesHelper.new(represented.work_package) - - attributes_helper.time_entries_sum + self.attributes_helper.time_entries_sum end send(:define_method, :current_user_allowed_to_view_spent_hours) do current_user_allowed_to(:view_time_entries, represented.work_package) || current_user_allowed_to(:view_own_time_entries, represented.work_package) end + + send(:define_method, :attributes_helper) do + @attributes_helper ||= OpenProject::Costs::AttributesHelper.new(represented.work_package) + end end assets %w(costs/costs.css costs/costs.js)