mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-20 03:47:11 +00:00
Merge pull request #57243 from frappe/mergify/bp/version-16-hotfix/pr-57223
fix(projects): include on hold status in project filters and reports (backport #57223)
This commit is contained in:
@@ -332,7 +332,9 @@ def bom(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@frappe.validate_and_sanitize_search_inputs
|
@frappe.validate_and_sanitize_search_inputs
|
||||||
def get_project_name(doctype, txt, searchfield, start, page_len, filters):
|
def get_project_name(
|
||||||
|
doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict | None = None
|
||||||
|
):
|
||||||
proj = qb.DocType("Project")
|
proj = qb.DocType("Project")
|
||||||
qb_filter_and_conditions = []
|
qb_filter_and_conditions = []
|
||||||
qb_filter_or_conditions = []
|
qb_filter_or_conditions = []
|
||||||
@@ -347,7 +349,7 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
if filters.get("company"):
|
if filters.get("company"):
|
||||||
qb_filter_and_conditions.append(proj.company == filters.get("company"))
|
qb_filter_and_conditions.append(proj.company == filters.get("company"))
|
||||||
|
|
||||||
qb_filter_and_conditions.append(proj.status.notin(["Completed", "Cancelled"]))
|
qb_filter_and_conditions.append(proj.status.notin(["Completed", "Cancelled", "On hold"]))
|
||||||
|
|
||||||
q = qb.from_(proj)
|
q = qb.from_(proj)
|
||||||
|
|
||||||
|
|||||||
@@ -299,6 +299,23 @@ class TestProject(ERPNextTestSuite):
|
|||||||
project.save()
|
project.save()
|
||||||
self.assertEqual(project.percent_complete, 100)
|
self.assertEqual(project.percent_complete, 100)
|
||||||
|
|
||||||
|
def test_on_hold_project_keeps_status(self):
|
||||||
|
project, tasks = self._project_with_tasks("Task Completion", 4)
|
||||||
|
|
||||||
|
# an On hold project is not auto-flipped to Completed even at 100%
|
||||||
|
project.status = "On hold"
|
||||||
|
for task in tasks:
|
||||||
|
frappe.db.set_value("Task", task, "status", "Completed")
|
||||||
|
project.update_percent_complete()
|
||||||
|
self.assertEqual(project.percent_complete, 100)
|
||||||
|
self.assertEqual(project.status, "On hold")
|
||||||
|
|
||||||
|
# nor auto-flipped back to Open when below 100%
|
||||||
|
frappe.db.set_value("Task", tasks[0], "status", "Open")
|
||||||
|
project.update_percent_complete()
|
||||||
|
self.assertEqual(project.percent_complete, 75)
|
||||||
|
self.assertEqual(project.status, "On hold")
|
||||||
|
|
||||||
def _create_portal_user(self, email):
|
def _create_portal_user(self, email):
|
||||||
"""A user with no Project-related role, so read access can only come from
|
"""A user with no Project-related role, so read access can only come from
|
||||||
control_access_for_project_users() sharing the doc with them."""
|
control_access_for_project_users() sharing the doc with them."""
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ frappe.ui.form.on("Task", {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
onload: function (frm) {
|
onload: function (frm) {
|
||||||
|
frm.set_query("project", function () {
|
||||||
|
return {
|
||||||
|
query: "erpnext.controllers.queries.get_project_name",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
frm.set_query("task", "depends_on", function () {
|
frm.set_query("task", "depends_on", function () {
|
||||||
let filters = {
|
let filters = {
|
||||||
name: ["!=", frm.doc.name],
|
name: ["!=", frm.doc.name],
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ frappe.ui.form.on("Timesheet", {
|
|||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
company: frm.doc.company,
|
company: frm.doc.company,
|
||||||
|
status: "Open",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -122,6 +123,7 @@ frappe.ui.form.on("Timesheet", {
|
|||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
customer: doc.customer,
|
customer: doc.customer,
|
||||||
|
status: "Open",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ frappe.query_reports["Project Summary"] = {
|
|||||||
fieldname: "status",
|
fieldname: "status",
|
||||||
label: __("Status"),
|
label: __("Status"),
|
||||||
fieldtype: "Select",
|
fieldtype: "Select",
|
||||||
options: "\nOpen\nCompleted\nCancelled",
|
options: "\nOpen\nOn hold\nCompleted\nCancelled",
|
||||||
default: "Open",
|
default: "Open",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user