fix: Project Template patch
This commit is contained in:
parent
c474caba70
commit
cf7209f3d4
@ -5,40 +5,41 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.reload_doc("projects", "doctype", "project_template")
|
frappe.reload_doc("projects", "doctype", "project_template")
|
||||||
frappe.reload_doc("projects", "doctype", "project_template_task")
|
frappe.reload_doc("projects", "doctype", "project_template_task")
|
||||||
frappe.reload_doc("projects", "doctype", "project_template")
|
frappe.reload_doc("projects", "doctype", "task")
|
||||||
frappe.reload_doc("projects", "doctype", "task")
|
|
||||||
|
|
||||||
for template_name in frappe.db.sql("""
|
# Update property setter status if any
|
||||||
select
|
property_setter_doc = frappe.get_doc('Property Setter', {'doc_type': 'Task',
|
||||||
name
|
'field_name': 'status', 'property': 'options'})
|
||||||
from
|
|
||||||
`tabProject Template` """,
|
|
||||||
as_dict=1):
|
|
||||||
|
|
||||||
template = frappe.get_doc("Project Template", template_name.name)
|
if property_setter_doc:
|
||||||
replace_tasks = False
|
property_setter_doc.value += "\nTemplate"
|
||||||
new_tasks = []
|
property_setter_doc.save()
|
||||||
for task in template.tasks:
|
|
||||||
if task.subject:
|
|
||||||
replace_tasks = True
|
|
||||||
new_task = frappe.get_doc(dict(
|
|
||||||
doctype = "Task",
|
|
||||||
subject = task.subject,
|
|
||||||
start = task.start,
|
|
||||||
duration = task.duration,
|
|
||||||
task_weight = task.task_weight,
|
|
||||||
description = task.description,
|
|
||||||
is_template = 1
|
|
||||||
)).insert()
|
|
||||||
new_tasks.append(new_task)
|
|
||||||
|
|
||||||
if replace_tasks:
|
for template_name in frappe.get_all('Project Template'):
|
||||||
template.tasks = []
|
template = frappe.get_doc("Project Template", template_name.name)
|
||||||
for tsk in new_tasks:
|
replace_tasks = False
|
||||||
template.append("tasks", {
|
new_tasks = []
|
||||||
"task": tsk.name,
|
for task in template.tasks:
|
||||||
"subject": tsk.subject
|
if task.subject:
|
||||||
})
|
replace_tasks = True
|
||||||
template.save()
|
new_task = frappe.get_doc(dict(
|
||||||
|
doctype = "Task",
|
||||||
|
subject = task.subject,
|
||||||
|
start = task.start,
|
||||||
|
duration = task.duration,
|
||||||
|
task_weight = task.task_weight,
|
||||||
|
description = task.description,
|
||||||
|
is_template = 1
|
||||||
|
)).insert()
|
||||||
|
new_tasks.append(new_task)
|
||||||
|
|
||||||
|
if replace_tasks:
|
||||||
|
template.tasks = []
|
||||||
|
for tsk in new_tasks:
|
||||||
|
template.append("tasks", {
|
||||||
|
"task": tsk.name,
|
||||||
|
"subject": tsk.subject
|
||||||
|
})
|
||||||
|
template.save()
|
Loading…
x
Reference in New Issue
Block a user