patch: split 'ongoing' sla status

This commit is contained in:
Saqib Ansari 2021-12-06 12:38:25 +05:30
parent defa01edac
commit f9408d170a
2 changed files with 28 additions and 0 deletions

View File

@ -312,3 +312,4 @@ erpnext.patches.v13_0.update_category_in_ltds_certificate
erpnext.patches.v13_0.create_pan_field_for_india #2
erpnext.patches.v14_0.delete_hub_doctypes
erpnext.patches.v13_0.create_ksa_vat_custom_fields
erpnext.patches.v14_0.rename_ongoing_status_in_sla_documents

View File

@ -0,0 +1,27 @@
import frappe
def execute():
active_sla_documents = [sla.document_type for sla in frappe.get_all("Service Level Agreement", fields=["document_type"])]
for doctype in active_sla_documents:
doctype = frappe.qb.DocType(doctype)
try:
query = (
frappe.qb
.update(doctype)
.set(doctype.agreement_status, 'First Response Due')
.where(
(doctype.first_responded_on.isnull()) | (doctype.first_responded_on == '')
)
)
query.run()
query = (
frappe.qb
.update(doctype)
.set(doctype.agreement_status, 'Resolution Due')
.where(doctype.agreement_status == 'Ongoing')
)
query.run()
except Exception as e:
frappe.log_error('Failed to Patch SLA Status')