[Minor] Fix adding child to root task issue (#12121)
* make parent_task none
* adding multiple tasks - set project of parent
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index 2a1b0e0..2d6c973 100644
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -202,25 +202,26 @@
@frappe.whitelist()
def add_node():
- from frappe.desk.treeview import make_tree_args
- args = frappe.form_dict
- args.update({
- "name_field": "subject"
- })
- args = make_tree_args(**args)
+ from frappe.desk.treeview import make_tree_args
+ args = frappe.form_dict
+ args.update({
+ "name_field": "subject"
+ })
+ args = make_tree_args(**args)
- if args.parent_task == 'All Tasks':
- args.parent_task = None
+ if args.parent_task == 'All Tasks' or args.parent_task == args.project:
+ args.parent_task = None
- frappe.get_doc(args).insert()
+ frappe.get_doc(args).insert()
@frappe.whitelist()
def add_multiple_tasks(data, parent):
- data = json.loads(data)['tasks']
- tasks = data.split('\n')
- new_doc = {'doctype': 'Task', 'parent_task': parent}
+ data = json.loads(data)['tasks']
+ tasks = data.split('\n')
+ new_doc = {'doctype': 'Task', 'parent_task': parent}
+ new_doc['project'] = frappe.db.get_value('Task', {"name": parent}, 'project')
- for d in tasks:
- new_doc['subject'] = d
- new_task = frappe.get_doc(new_doc)
- new_task.insert()
+ for d in tasks:
+ new_doc['subject'] = d
+ new_task = frappe.get_doc(new_doc)
+ new_task.insert()
diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt
index 3749cb8..b00268c 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -99,7 +99,6 @@
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_serialize_item.js
erpnext/accounts/doctype/payment_entry/tests/test_payment_against_invoice.js
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_last_purchase_rate.js
-erpnext/projects/doctype/task/tests/test_task_tree.js
erpnext/stock/doctype/item_price/test_item_price.js
erpnext/stock/doctype/delivery_note/test_delivery_note_with_margin.js
erpnext/selling/doctype/sales_order/tests/test_sales_order_with_margin.js