patch: refactor patch for travis test

This commit is contained in:
Himanshu Warekar 2019-06-18 19:35:50 +05:30
parent befd393dcb
commit 7881e838c6

View File

@ -2,30 +2,32 @@ import frappe
def execute(): def execute():
frappe.reload_doc("support", "doctype", "issue_priority") frappe.reload_doc("support", "doctype", "issue_priority")
frappe.reload_doc("support", "doctype", "service_level_priority")
priorities = frappe.get_meta("Issue").get_field("priority").options.split("\n") set_issue_priority()
set_priority_for_issue()
set_priorities_service_level()
set_priorities_service_level_agreement()
for priority in priorities: def set_issue_priority():
for priority in frappe.get_meta("Issue").get_field("priority").options.split("\n"):
if not frappe.db.exists("Issue Priority", priority): if not frappe.db.exists("Issue Priority", priority):
frappe.get_doc({ frappe.get_doc({
"doctype": "Issue Priority", "doctype": "Issue Priority",
"name": priority "name": priority
}).insert(ignore_permissions=True) }).insert(ignore_permissions=True)
def set_priority_for_issue():
issue_priority = frappe.get_list("Issue", fields=["name", "priority"]) issue_priority = frappe.get_list("Issue", fields=["name", "priority"])
service_level_priority = frappe.get_list("Service Level", fields=["name", "priority", "response_time", "response_time_period", "resolution_time", "resolution_time_period"])
service_level_agreement_priority = frappe.get_list("Service Level Agreement", fields=["name", "priority", "response_time", "response_time_period", "resolution_time", "resolution_time_period"])
frappe.reload_doc("support", "doctype", "issue") frappe.reload_doc("support", "doctype", "issue")
frappe.reload_doc("support", "doctype", "service_level_priority")
frappe.reload_doc("support", "doctype", "service_level")
frappe.reload_doc("support", "doctype", "service_level_agreement")
for issue in issue_priority: for issue in issue_priority:
frappe.db.set_value("Issue", issue.name, "priority", issue.priority) frappe.db.set_value("Issue", issue.name, "priority", issue.priority)
def set_priorities_service_level():
service_level_priorities = frappe.get_list("Service Level", fields=["name", "priority", "response_time", "response_time_period", "resolution_time", "resolution_time_period"])
frappe.reload_doc("support", "doctype", "service_level")
for service_level in service_level_priority: for service_level in service_level_priority:
doc = frappe.get_doc("Service Level", service_level.name) doc = frappe.get_doc("Service Level", service_level.name)
doc.append("priorities", { doc.append("priorities", {
@ -38,8 +40,11 @@ def execute():
}) })
doc.save(ignore_permissions=True) doc.save(ignore_permissions=True)
for service_level_agreement in service_level_agreement_priority: def set_priorities_service_level_agreement():
service_level_agreement_priority = frappe.get_list("Service Level Agreement", fields=["name", "priority", "response_time", "response_time_period", "resolution_time", "resolution_time_period"])
frappe.reload_doc("support", "doctype", "service_level_agreement")
for service_level_agreement in service_level_agreement_priority:
doc = frappe.get_doc("Service Level Agreement", service_level_agreement.name) doc = frappe.get_doc("Service Level Agreement", service_level_agreement.name)
if doc.customer: if doc.customer: