Feature #11989

Allow done ratios to be affected by status AND field

Added by Brian Lindahl about 6 years ago. Updated about 6 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

50%

Category:Issues workflow
Target version:-
Resolution:

Description

Consider a situation where a defect can be re-opened, or a defect can be moved to the 'resolved'/'released' state, but requires verification before it can be closed. It'd be nice to have the 'resolved'/'released' status the done ratio to 100%, but, if you do that, then you lose the capability to track progress during the 'in progress' state.

Here's a fix that allows for both (version 2.1.0):

diff -rupN redmine-2.1.0/app/models/issue.rb redmine-2.1.0-modified/app/models/issue.rb
--- redmine-2.1.0/app/models/issue.rb       2012-09-16 06:54:11.000000000 -0600
+++ redmine-2.1.0-modified/app/models/issue.rb        2012-09-28 11:16:32.479809960 -0600
@@ -49,7 +49,7 @@ class Issue < ActiveRecord::Base
   acts_as_activity_provider :find_options => {:include => [:project, :author, :tracker]},
                             :author_key => :author_id

-  DONE_RATIO_OPTIONS = %w(issue_field issue_status)
+  DONE_RATIO_OPTIONS = %w(issue_field issue_status issue_field_and_status)

   attr_reader :current_journal

@@ -494,6 +496,10 @@ class Issue < ActiveRecord::Base
   def self.use_field_for_done_ratio?
     Setting.issue_done_ratio == 'issue_field'
   end
+
+  def use_field_for_done_ratio?
+    Setting.issue_done_ratio == 'issue_field' || (Setting.issue_done_ratio == 'issue_field_or_status' && status && status.default_done_ratio.nil?)
+  end

   def validate_issue
     if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
diff -rupN redmine-2.1.0/app/views/context_menus/issues.html.erb redmine-2.1.0-modified/app/views/context_menus/issues.html.erb
--- redmine-2.1.0/app/views/context_menus/issues.html.erb   2012-09-16 06:54:12.000000000 -0600
+++ redmine-2.1.0-modified/app/views/context_menus/issues.html.erb    2012-09-28 11:11:07.979813055 -0600
@@ -91,7 +91,7 @@
   </li>
   <% end -%>

-  <% if @safe_attributes.include?('done_ratio') && Issue.use_field_for_done_ratio? %>
+  <% if @safe_attributes.include?('done_ratio') && @issue.use_field_for_done_ratio %>
   <li class="folder">
     <a href="#" class="submenu"><%= l(:field_done_ratio) %></a>
     <ul>
diff -rupN redmine-2.1.0/app/views/issues/_attributes.html.erb redmine-2.1.0-modified/app/views/issues/_attributes.html.erb
--- redmine-2.1.0/app/views/issues/_attributes.html.erb     2012-09-16 06:54:13.000000000 -0600
+++ redmine-2.1.0-modified/app/views/issues/_attributes.html.erb      2012-09-28 11:10:31.103813406 -0600
@@ -58,7 +58,7 @@
 <p><%= f.text_field :estimated_hours, :size => 3, :disabled => !@issue.leaf?, :required => @issue.required_attribute?('estimated_hours') %> <%= l(:field_hours) %></p>
 <% end %>

-<% if @issue.safe_attribute?('done_ratio') && @issue.leaf? && Issue.use_field_for_done_ratio? %>
+<% if @issue.safe_attribute?('done_ratio') && @issue.leaf? && @issue.use_field_for_done_ratio? %>
 <p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :required => @issue.required_attribute?('done_ratio') %></p>
 <% end %>
 </div>
diff -rupN redmine-2.1.0/app/views/issue_statuses/_form.html.erb redmine-2.1.0-modified/app/views/issue_statuses/_form.html.erb
--- redmine-2.1.0/app/views/issue_statuses/_form.html.erb   2012-09-16 06:54:12.000000000 -0600
+++ redmine-2.1.0-modified/app/views/issue_statuses/_form.html.erb    2012-09-28 11:18:48.535808664 -0600
@@ -2,7 +2,7 @@

 <div class="box tabular">
 <p><%= f.text_field :name, :required => true %></p>
-<% if Issue.use_status_for_done_ratio? %>
+<% if not Issue.use_field_for_done_ratio? %>
   <p><%= f.select :default_done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :include_blank => true, :label => :field_done_ratio %></p>
 <% end %>
 <p><%= f.check_box :is_closed %></p>
diff -rupN redmine-2.1.0/app/views/issue_statuses/index.html.erb redmine-2.1.0-modified/app/views/issue_statuses/index.html.erb
--- redmine-2.1.0/app/views/issue_statuses/index.html.erb   2012-09-16 06:54:12.000000000 -0600
+++ redmine-2.1.0-modified/app/views/issue_statuses/index.html.erb    2012-09-28 11:19:39.799808172 -0600
@@ -1,6 +1,6 @@
 <div class="contextual">
 <%= link_to l(:label_issue_status_new), new_issue_status_path, :class => 'icon icon-add' %>
-<%= link_to(l(:label_update_issue_done_ratios), update_issue_done_ratio_issue_statuses_path, :class => 'icon icon-multiple', :method => 'post', :data => {:confirm => l(:text_are_you_sure)}) if Issue.use_status_for_done_ratio? %>
+<%= link_to(l(:label_update_issue_done_ratios), update_issue_done_ratio_issue_statuses_path, :class => 'icon icon-multiple', :method => 'post', :data => {:confirm => l(:text_are_you_sure)}) if not Issue.use_field_for_done_ratio? %>
 </div>

 <h2><%=l(:label_issue_status_plural)%></h2>
@@ -8,7 +8,7 @@
 <table class="list">
   <thead><tr>
   <th><%=l(:field_status)%></th>
-  <% if Issue.use_status_for_done_ratio? %>
+  <% if not Issue.use_field_for_done_ratio? %>
   <th><%=l(:field_done_ratio)%></th>
   <% end %>
   <th><%=l(:field_is_default)%></th>
@@ -20,7 +20,7 @@
 <% for status in @issue_statuses %>
   <tr class="<%= cycle("odd", "even") %>">
   <td><%= link_to h(status.name), edit_issue_status_path(status) %></td>
-  <% if Issue.use_status_for_done_ratio? %>
+  <% if not Issue.use_field_for_done_ratio? %>
   <td align="center"><%= h status.default_done_ratio %></td>
   <% end %>
   <td align="center"><%= checked_image status.is_default? %></td>
diff -rupN redmine-2.1.0/config/locales/en.yml redmine-2.1.0-modified/config/locales/en.yml
--- redmine-2.1.0/config/locales/en.yml 2012-09-16 06:54:19.000000000 -0600
+++ redmine-2.1.0-modified/config/locales/en.yml 2012-09-28 11:13:35.371811650 -0600
@@ -382,6 +382,7 @@ en:
   setting_issue_done_ratio: Calculate the issue done ratio with
   setting_issue_done_ratio_issue_field: Use the issue field
   setting_issue_done_ratio_issue_status: Use the issue status
+  setting_issue_done_ratio_issue_field_and_status: Use the issue field and status

History

#1 Updated by Marcus Fleuti about 6 years ago

This is similar to the current feature request I am having: #11999 .

In my opinion the calculation of the "issue done ratios" is yet a bit too static. It should also be possible to have a different behavior on a project basis. We would need to have different ratio calculation types in different projects because we use Redmine to manage not only software development project tasks but also to solve customer support issues.

Also available in: Atom PDF