diff --git a/erpnext/patches/v12_0/move_parameters_to_priority.py b/erpnext/patches/v12_0/move_parameters_to_priority.py index 9d031c379b..a08ab6dcc9 100644 --- a/erpnext/patches/v12_0/move_parameters_to_priority.py +++ b/erpnext/patches/v12_0/move_parameters_to_priority.py @@ -7,34 +7,60 @@ import frappe def execute(): priorities = ["Low", "Medium", "High"] - service_levels = frappe.get_list("Service Level", - fields=["name", "priority", "response_time", "response_time_period", "resolution_time", "resolution_time_period"]) + service_levels = frappe.get_list("Service Level") for service_level in service_levels: - for idx, value in enumerate(priorities): - doc = frappe.get_doc({ - "doctype": "Service Level Priority", - "parent": service_level.name, - "parenttype": "Service Level", - "priority": value, - "idx": idx, - "response_time": service_level.response_time, - "response_time_period": service_level.response_time_period, - "resolution_time": service_level.resolution_time, - "resolution_time_period": service_level.resolution_time_period, - }).insert(ignore_permissions=True) + doc = frappe.get_doc("Service Level", service_level) + doc.update({ + "priority": [ + { + "priority": "Low", + "response_time": service_level.response_time, + "response_time_period": service_level.response_time_period, + "resolution_time": service_level.resolution_time, + "resolution_time_period": service_level.resolution_time_period, + }, + { + "priority": "Medium", + "response_time": service_level.response_time, + "response_time_period": service_level.response_time_period, + "resolution_time": service_level.resolution_time, + "resolution_time_period": service_level.resolution_time_period, + }, + { + "priority": "High", + "response_time": service_level.response_time, + "response_time_period": service_level.response_time_period, + "resolution_time": service_level.resolution_time, + "resolution_time_period": service_level.resolution_time_period, + } + ] + }) - service_level_agreements = frappe.get_list("Service Level Agreement", - fields=["name", "priority", "response_time", "response_time_period", "resolution_time", "resolution_time_period"]) + service_level_agreements = frappe.get_list("Service Level Agreement") for service_level_agreement in service_level_agreements: - for idx, value in enumerate(priorities): - doc = frappe.get_doc({ - "doctype": "Service Level Priority", - "parent": service_level_agreement.name, - "parenttype": "Service Level Agreement", - "priority": value, - "idx": idx, - "response_time": service_level_agreement.response_time, - "response_time_period": service_level_agreement.response_time_period, - "resolution_time": service_level_agreement.resolution_time, - "resolution_time_period": service_level_agreement.resolution_time_period, - }).insert(ignore_permissions=True) \ No newline at end of file + doc = frappe.get_doc("Service Level Agreement", service_level_agreement) + doc.update({ + "priority": [ + { + "priority": "Low", + "response_time": service_level_agreement.response_time, + "response_time_period": service_level_agreement.response_time_period, + "resolution_time": service_level_agreement.resolution_time, + "resolution_time_period": service_level_agreement.resolution_time_period, + }, + { + "priority": "Medium", + "response_time": service_level_agreement.response_time, + "response_time_period": service_level_agreement.response_time_period, + "resolution_time": service_level_agreement.resolution_time, + "resolution_time_period": service_level_agreement.resolution_time_period, + }, + { + "priority": "High", + "response_time": service_level_agreement.response_time, + "response_time_period": service_level_agreement.response_time_period, + "resolution_time": service_level_agreement.resolution_time, + "resolution_time_period": service_level_agreement.resolution_time_period, + }, + ] + })