From 6c9a92671bb1e2f5e0c74da98fbdf4bf02fa5132 Mon Sep 17 00:00:00 2001 From: Benji Date: Wed, 5 Sep 2018 15:54:53 +0800 Subject: [PATCH] Minor bugfix (#15210) * Minor bugfix Bugfix for https://github.com/frappe/erpnext/pull/15170 * Update project.py --- erpnext/projects/doctype/project/project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index 8b73b9b392..4fd8e81bba 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -86,7 +86,7 @@ class Project(Document): def validate_weights(self): for task in self.tasks: if task.task_weight is not None: - if task.task_weight > 0: + if task.task_weight < 0: frappe.throw(_("Task weight cannot be negative")) def sync_tasks(self): @@ -208,7 +208,7 @@ class Project(Document): project=%s""", self.name, as_dict=1) pct_complete = 0 for row in weighted_progress: - pct_complete += row["progress"] * row["task_weight"] / weight_sum + pct_complete += row["progress"] * frappe.utils.safe_div(row["task_weight"], weight_sum) self.percent_complete = flt(flt(pct_complete), 2) if self.percent_complete == 100: self.status = "Completed"