mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-13 14:41:53 +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.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")
|
||||
qb_filter_and_conditions = []
|
||||
qb_filter_or_conditions = []
|
||||
@@ -347,7 +349,7 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters):
|
||||
if 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)
|
||||
|
||||
|
||||
@@ -299,6 +299,23 @@ class TestProject(ERPNextTestSuite):
|
||||
project.save()
|
||||
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):
|
||||
"""A user with no Project-related role, so read access can only come from
|
||||
control_access_for_project_users() sharing the doc with them."""
|
||||
|
||||
@@ -14,6 +14,12 @@ frappe.ui.form.on("Task", {
|
||||
};
|
||||
},
|
||||
onload: function (frm) {
|
||||
frm.set_query("project", function () {
|
||||
return {
|
||||
query: "erpnext.controllers.queries.get_project_name",
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("task", "depends_on", function () {
|
||||
let filters = {
|
||||
name: ["!=", frm.doc.name],
|
||||
|
||||
@@ -30,6 +30,7 @@ frappe.ui.form.on("Timesheet", {
|
||||
return {
|
||||
filters: {
|
||||
company: frm.doc.company,
|
||||
status: "Open",
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -122,6 +123,7 @@ frappe.ui.form.on("Timesheet", {
|
||||
return {
|
||||
filters: {
|
||||
customer: doc.customer,
|
||||
status: "Open",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ frappe.query_reports["Project Summary"] = {
|
||||
fieldname: "status",
|
||||
label: __("Status"),
|
||||
fieldtype: "Select",
|
||||
options: "\nOpen\nCompleted\nCancelled",
|
||||
options: "\nOpen\nOn hold\nCompleted\nCancelled",
|
||||
default: "Open",
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user