anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
182 stars 72 forks source link

Update Project Custom Field with sum of all Time Entries #238

Closed bennopj closed 2 years ago

bennopj commented 2 years ago

Hi @tibillys, did you manage to solve that? Trying to do the same but struggling.

I have a calculated customer field in project that sums the Time Entries (of everything below that project). But in order to update this field i must go to project settings and just press save.

So i was thinking that i could use your plugin in order to save the project after a time entry.

_Originally posted by @tibillys in https://github.com/anteo/redmine_custom_workflows/issues/154#issuecomment-582270864_

AirTibu commented 2 years ago

Hi,

You should create a computed project custom field, with this code:


TimeEntry.where(:project => self.project.id ).sum(:hours).to_f

image

You should create an ISSUE custom workflow to save the project to update project custom_field:

AFTER SAVE


self.project.save unless project.nil?

I hope it helps!

lublasco commented 2 years ago

Hi, the "after save" code snippet works properly when including the time entry on issue edit page, but not if the user inputs the time through the log time form.

AirTibu commented 2 years ago

Hi,

Create a TimeEntry type custom workflow and add the same code this new flow.

lublasco commented 2 years ago

Worked perfectly. Thanks a lot for your help, @AirTibu !