mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
feat: patch for project template tasks
This commit is contained in:
@@ -741,3 +741,4 @@ erpnext.patches.v13_0.updates_for_multi_currency_payroll
|
|||||||
erpnext.patches.v13_0.create_leave_policy_assignment_based_on_employee_current_leave_policy
|
erpnext.patches.v13_0.create_leave_policy_assignment_based_on_employee_current_leave_policy
|
||||||
erpnext.patches.v13_0.add_po_to_global_search
|
erpnext.patches.v13_0.add_po_to_global_search
|
||||||
erpnext.patches.v13_0.update_returned_qty_in_pr_dn
|
erpnext.patches.v13_0.update_returned_qty_in_pr_dn
|
||||||
|
erpnext.patches.v13_0.update_project_template_tasks
|
||||||
|
|||||||
32
erpnext/patches/v13_0/update_project_template_tasks.py
Normal file
32
erpnext/patches/v13_0/update_project_template_tasks.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Copyright (c) 2019, Frappe and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
templates = frappe.get_list("Project Template", fields = ["name"])
|
||||||
|
for template_name in templates:
|
||||||
|
template = frappe.get_doc("Project Template", template_name)
|
||||||
|
replace_tasks = False
|
||||||
|
new_tasks = []
|
||||||
|
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.name)
|
||||||
|
if replace_tasks:
|
||||||
|
template.tasks = []
|
||||||
|
for tsk in new_tasks:
|
||||||
|
template.append("tasks", {
|
||||||
|
"task": tsk
|
||||||
|
})
|
||||||
|
template.save()
|
||||||
Reference in New Issue
Block a user