brotherton-erpnext/erpnext/patches/v5_0/update_projects.py

29 lines
903 B
Python
Raw Normal View History

import frappe
def execute():
# convert milestones to tasks
frappe.reload_doctype("Project")
2015-04-24 10:37:32 +00:00
frappe.reload_doc("projects", "doctype", "project_task")
frappe.reload_doctype("Task")
2015-05-15 09:14:52 +00:00
frappe.reload_doc("projects", "doctype", "task_depends_on")
for m in frappe.get_all("Project Milestone", "*"):
2015-02-26 14:57:41 +00:00
if (m.milestone and m.milestone_date
and frappe.db.exists("Project", m.parent)):
2015-05-26 11:02:30 +00:00
task = frappe.get_doc({
2015-02-24 07:35:34 +00:00
"doctype": "Task",
"subject": m.milestone,
"expected_start_date": m.milestone_date,
"status": "Open" if m.status=="Pending" else "Closed",
"project": m.parent,
2015-05-26 11:02:30 +00:00
})
task.flags.ignore_mandatory = True
task.insert(ignore_permissions=True)
# remove project milestone
frappe.delete_doc("DocType", "Project Milestone")
# remove calendar events for milestone
for e in frappe.get_all("Event", ["name"], {"ref_type": "Project"}):
frappe.delete_doc("Event", e.name)