OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
more places work_pakcage -> entity
Klaus Zanders6ff26486f336
diff --git a/modules/costs/app/components/time_entries/activity_form.rb b/modules/costs/app/components/time_entries/activity_form.rbindex 6c9f137f56e..af491adc59c 100644--- a/modules/costs/app/components/time_entries/activity_form.rb+++ b/modules/costs/app/components/time_entries/activity_form.rb@@ -53,14 +53,14 @@ module TimeEntriesprivate- delegate :project, :work_package, to: :model+ delegate :project, :entity, to: :model- def project_or_work_package_selected?- work_package.present? || project.present?+ def project_or_entity_selected?+ entity.present? || project.present?enddef placeholder_text- I18n.t("placeholder_activity_select_work_package_first") unless project_or_work_package_selected?+ I18n.t("placeholder_activity_select_work_package_first") unless project_or_entity_selected?enddef activitiesdiff --git a/modules/costs/app/components/time_entries/entity_form.rb b/modules/costs/app/components/time_entries/entity_form.rbindex ec53256469c..bd73051da8f 100644--- a/modules/costs/app/components/time_entries/entity_form.rb+++ b/modules/costs/app/components/time_entries/entity_form.rb@@ -58,14 +58,14 @@ module TimeEntriesfilters: work_package_completer_filters}else- f.hidden name: :work_package_id, value: model.work_package_id+ f.hidden name: :entity_id, value: model.entity_idendendprivatedef show_work_package_field?- return true if model.work_package_id.nil?+ return true if model.entity_id.nil?@visibleend@@ -92,7 +92,7 @@ module TimeEntriesif model.errors[:project_id].present?model.errors[:project_id].firstelse- model.errors[:work_package]&.first+ model.errors[:entities]&.firstendenddiff --git a/modules/costs/app/controllers/costlog_controller.rb b/modules/costs/app/controllers/costlog_controller.rbindex 531664914d3..4a49d145d8b 100644--- a/modules/costs/app/controllers/costlog_controller.rb+++ b/modules/costs/app/controllers/costlog_controller.rb@@ -57,7 +57,7 @@ class CostlogController < ApplicationControllerelsif @cost_entry.saveflash[:notice] = t(:notice_cost_logged_successfully)- redirect_back_or_default work_package_path(@cost_entry.work_package)+ redirect_back_or_default work_package_path(@cost_entry.entity)elserender action: :edit, status: :unprocessable_entityend@@ -73,7 +73,7 @@ class CostlogController < ApplicationControllerelsif @cost_entry.saveflash[:notice] = t(:notice_successful_update)- redirect_back fallback_location: work_package_path(@cost_entry.work_package)+ redirect_back fallback_location: work_package_path(@cost_entry.entity)elserender action: "edit"@@ -90,7 +90,7 @@ class CostlogController < ApplicationControllerif request.referer.include?("cost_reports")redirect_to controller: "/cost_reports", action: :indexelse- redirect_back fallback_location: work_package_path(@cost_entry.work_package)+ redirect_back fallback_location: work_package_path(@cost_entry.entity)endend@@ -121,8 +121,8 @@ class CostlogController < ApplicationControllerendwork_package_id = cost_entry_params.delete(:work_package_id)- @work_package = if @cost_entry.present? && @cost_entry.work_package_id == work_package_id- @cost_entry.work_package+ @work_package = if @cost_entry.present? && @cost_entry.entity_type == "WorkPackage" && @cost_entry.enity_id == work_package_id+ @cost_entry.entityelseWorkPackage.find_by(id: work_package_id)end@@ -138,7 +138,7 @@ class CostlogController < ApplicationControllerdef new_default_cost_entry@cost_entry = CostEntry.new.tap do |ce|ce.project = @project- ce.work_package = @work_package+ ce.entity = @work_packagece.user = User.currentce.spent_on = Time.zone.today# notice that cost_type is set to default cost_type in the model@@ -147,7 +147,7 @@ class CostlogController < ApplicationControllerdef update_cost_entry_from_params@cost_entry.user = @user- @cost_entry.work_package = @work_package+ @cost_entry.entity = @work_package@cost_entry.cost_type = @cost_typeattributes = permitted_params.cost_entrydiff --git a/modules/costs/app/controllers/time_entries_controller.rb b/modules/costs/app/controllers/time_entries_controller.rbindex 9f8f81cdb65..ec7043c3033 100644--- a/modules/costs/app/controllers/time_entries_controller.rb+++ b/modules/costs/app/controllers/time_entries_controller.rb@@ -223,7 +223,7 @@ class TimeEntriesController < ApplicationControllerentryendelse- TimeEntry.new(project: @project, work_package: @work_package, user: User.current)+ TimeEntry.new(project: @project, entity: @work_package, user: User.current)endendenddiff --git a/modules/costs/app/models/cost_entry.rb b/modules/costs/app/models/cost_entry.rbindex 4cb9fa21d98..fd68708a572 100644--- a/modules/costs/app/models/cost_entry.rb+++ b/modules/costs/app/models/cost_entry.rb@@ -74,13 +74,13 @@ class CostEntry < ApplicationRecordenddef before_validation- self.project = work_package.project if work_package && project.nil?+ self.project = entity.project if entity && project.nil?enddef validateerrors.add :units, :invalid if units&.negative?errors.add :project_id, :invalid if project.nil?- errors.add :work_package_id, :invalid if work_package.nil? || (project != work_package.project)+ errors.add :entity, :invalid if entity.nil? || (project != entity.project)errors.add :cost_type_id, :invalid if cost_type.present? && cost_type.deleted_at.present?errors.add :user_id, :invalid if project.present? && project.users.exclude?(user) && user_id_changed?diff --git a/modules/costs/spec/features/my_time_tracking_spec.rb b/modules/costs/spec/features/my_time_tracking_spec.rbindex 0ef3eefa785..b85bbab5108 100644--- a/modules/costs/spec/features/my_time_tracking_spec.rb+++ b/modules/costs/spec/features/my_time_tracking_spec.rb@@ -45,18 +45,18 @@ RSpec.describe "my time tracking", :js dolet(:project2) { create(:project_with_types) }let(:work_package1) { create(:work_package, project: project1) }let(:work_package2) { create(:work_package, project: project2) }- let!(:time_entry1) { create(:time_entry, user:, work_package: work_package1, spent_on: "2025-04-07", hours: 6.5) }+ let!(:time_entry1) { create(:time_entry, user:, entity: work_package1, spent_on: "2025-04-07", hours: 6.5) }let!(:time_entry2) do- create(:time_entry, work_package: work_package1, user:, spent_on: "2025-04-09", hours: 1.0, start_time: (9 * 60) + 30,+ create(:time_entry, entity: work_package1, user:, spent_on: "2025-04-09", hours: 1.0, start_time: (9 * 60) + 30,time_zone:)end- let!(:time_entry3) { create(:time_entry, user:, work_package: work_package1, spent_on: "2025-04-14", hours: 3.0) }- let!(:time_entry4) { create(:time_entry, user:, work_package: work_package2, spent_on: "2025-04-09", hours: 2.0) }+ let!(:time_entry3) { create(:time_entry, user:, entity: work_package1, spent_on: "2025-04-14", hours: 3.0) }+ let!(:time_entry4) { create(:time_entry, user:, entity: work_package2, spent_on: "2025-04-09", hours: 2.0) }let!(:time_entry5) do- create(:time_entry, user:, work_package: work_package2, spent_on: "2025-04-09", hours: 1.0, start_time: (13 * 60) + 30,+ create(:time_entry, user:, entity: work_package2, spent_on: "2025-04-09", hours: 1.0, start_time: (13 * 60) + 30,time_zone:)end- let!(:time_entry6) { create(:time_entry, user:, work_package: work_package2, spent_on: "2025-04-14", hours: 2.0) }+ let!(:time_entry6) { create(:time_entry, user:, entity: work_package2, spent_on: "2025-04-14", hours: 2.0) }let(:allow_exact_time_tracking) { true }let(:force_exact_time_tracking) { false }diff --git a/modules/costs/spec/models/work_package_spec.rb b/modules/costs/spec/models/work_package_spec.rbindex a61f2574a7e..4839adee380 100644--- a/modules/costs/spec/models/work_package_spec.rb+++ b/modules/costs/spec/models/work_package_spec.rb@@ -42,7 +42,7 @@ RSpec.describe WorkPackage doauthor: user)endlet!(:cost_entry) do- create(:cost_entry, work_package:, project:, units: 3, spent_on: Date.today, user:,+ create(:cost_entry, entity: work_package, project:, units: 3, spent_on: Date.current, user:,comments: "test entry")endlet!(:budget) { create(:budget, project:) }