Merge pull request #16029 from Alchez/hotfix-child-task-error
Fix error when trying to convert a task into a group even if no child tasks exist
This commit is contained in:
commit
15ca2f438f
@ -80,15 +80,15 @@ frappe.ui.form.on("Task", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
is_group: function(frm) {
|
is_group: function (frm) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method:"erpnext.projects.doctype.task.task.check_if_child_exists",
|
method: "erpnext.projects.doctype.task.task.check_if_child_exists",
|
||||||
args: {
|
args: {
|
||||||
name: frm.doc.name
|
name: frm.doc.name
|
||||||
},
|
},
|
||||||
callback: function(r){
|
callback: function (r) {
|
||||||
if(r.message){
|
if (r.message.length > 0) {
|
||||||
frappe.msgprint(__('Cannot convert it to non-group. Child Tasks exist.'));
|
frappe.msgprint(__(`Cannot convert it to non-group. The following child Tasks exist: ${r.message.join(", ")}.`));
|
||||||
frm.reload_doc();
|
frm.reload_doc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,15 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, json
|
|
||||||
|
|
||||||
from frappe.utils import getdate, date_diff, add_days, cstr
|
import json
|
||||||
|
|
||||||
|
import frappe
|
||||||
from frappe import _, throw
|
from frappe import _, throw
|
||||||
|
from frappe.utils import add_days, cstr, date_diff, get_link_to_form, getdate
|
||||||
from frappe.utils.nestedset import NestedSet
|
from frappe.utils.nestedset import NestedSet
|
||||||
|
|
||||||
|
|
||||||
class CircularReferenceError(frappe.ValidationError): pass
|
class CircularReferenceError(frappe.ValidationError): pass
|
||||||
|
|
||||||
class Task(NestedSet):
|
class Task(NestedSet):
|
||||||
@ -157,8 +160,10 @@ class Task(NestedSet):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def check_if_child_exists(name):
|
def check_if_child_exists(name):
|
||||||
return frappe.db.sql("""select name from `tabTask`
|
child_tasks = frappe.get_all("Task", filters={"parent_task": name})
|
||||||
where parent_task = %s""", name)
|
child_tasks = [get_link_to_form("Task", task.name) for task in child_tasks]
|
||||||
|
return child_tasks
|
||||||
|
|
||||||
|
|
||||||
def get_project(doctype, txt, searchfield, start, page_len, filters):
|
def get_project(doctype, txt, searchfield, start, page_len, filters):
|
||||||
from erpnext.controllers.queries import get_match_cond
|
from erpnext.controllers.queries import get_match_cond
|
||||||
|
Loading…
x
Reference in New Issue
Block a user