-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update the project after task deletion so that the % completed s… (
#22591) * fix: update the project after task deletion so that the % completed shows correct value * fix: patch to correct % complete of previous projects * fix: for version-13 * fix: removed patch from v13 Co-authored-by: Marica <maricadsouza221197@gmail.com> Co-authored-by: Anurag Mishra <32095923+Anurag810@users.noreply.github.com> Co-authored-by: Nabin Hait <nabinhait@gmail.com>
- Loading branch information
1 parent
91fe106
commit ecb1460
Showing
3 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
erpnext/patches/v12_0/fix_percent_complete_for_projects.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import frappe | ||
from frappe.utils import flt | ||
|
||
def execute(): | ||
for project in frappe.get_all("Project", fields=["name", "percent_complete_method"]): | ||
total = frappe.db.count('Task', dict(project=project.name)) | ||
if project.percent_complete_method == "Task Completion" and total > 0: | ||
completed = frappe.db.sql("""select count(name) from tabTask where | ||
project=%s and status in ('Cancelled', 'Completed')""", project.name)[0][0] | ||
percent_complete = flt(flt(completed) / total * 100, 2) | ||
if project.percent_complete != percent_complete: | ||
frappe.db.set_value("Project", project.name, "percent_complete", percent_complete) | ||
if percent_complete == 100: | ||
frappe.db.set_value("Project", project.name, "status", "Completed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters