refactor: do not allow submittable doctypes for SLA
This commit is contained in:
parent
a9ab157198
commit
a68fc546e7
@ -111,6 +111,7 @@ frappe.ui.form.on('Service Level Agreement', {
|
|||||||
filters: [
|
filters: [
|
||||||
['DocType', 'issingle', '=', 0],
|
['DocType', 'issingle', '=', 0],
|
||||||
['DocType', 'istable', '=', 0],
|
['DocType', 'istable', '=', 0],
|
||||||
|
['DocType', 'is_submittable', '=', 0],
|
||||||
['DocType', 'name', 'not in', invalid_doctypes],
|
['DocType', 'name', 'not in', invalid_doctypes],
|
||||||
['DocType', 'module', 'not in', ["Email", "Core", "Custom", "Event Streaming", "Social", "Data Migration", "Geo", "Desk"]]
|
['DocType', 'module', 'not in', ["Email", "Core", "Custom", "Event Streaming", "Social", "Data Migration", "Geo", "Desk"]]
|
||||||
]
|
]
|
||||||
|
|||||||
@ -29,6 +29,7 @@ from erpnext.support.doctype.issue.issue import get_holidays
|
|||||||
|
|
||||||
class ServiceLevelAgreement(Document):
|
class ServiceLevelAgreement(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
self.validate_selected_doctype()
|
||||||
self.validate_doc()
|
self.validate_doc()
|
||||||
self.validate_status_field()
|
self.validate_status_field()
|
||||||
self.check_priorities()
|
self.check_priorities()
|
||||||
@ -106,6 +107,23 @@ class ServiceLevelAgreement(Document):
|
|||||||
frappe.throw(_("Service Level Agreement for {0} {1} already exists.").format(
|
frappe.throw(_("Service Level Agreement for {0} {1} already exists.").format(
|
||||||
frappe.bold(self.entity_type), frappe.bold(self.entity)))
|
frappe.bold(self.entity_type), frappe.bold(self.entity)))
|
||||||
|
|
||||||
|
def validate_selected_doctype(self):
|
||||||
|
invalid_doctypes = list(frappe.model.core_doctypes_list)
|
||||||
|
invalid_doctypes.extend(['Cost Center', 'Company'])
|
||||||
|
valid_document_types = frappe.get_all('DocType', {
|
||||||
|
'issingle': 0,
|
||||||
|
'istable': 0,
|
||||||
|
'is_submittable': 0,
|
||||||
|
'name': ['not in', invalid_doctypes],
|
||||||
|
'module': ['not in', ["Email", "Core", "Custom", "Event Streaming", "Social", "Data Migration", "Geo", "Desk"]]
|
||||||
|
}, pluck="name")
|
||||||
|
|
||||||
|
if self.document_type not in valid_document_types:
|
||||||
|
frappe.throw(
|
||||||
|
msg=_("Please select valid document type."),
|
||||||
|
title=_("Invalid Document Type")
|
||||||
|
)
|
||||||
|
|
||||||
def validate_status_field(self):
|
def validate_status_field(self):
|
||||||
meta = frappe.get_meta(self.document_type)
|
meta = frappe.get_meta(self.document_type)
|
||||||
if not meta.get_field("status"):
|
if not meta.get_field("status"):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user