fix: allow start/end date for sla
This commit is contained in:
parent
ebb8502e54
commit
47708b1cbe
@ -2,6 +2,8 @@ import frappe
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.query_builder import JoinType
|
from frappe.query_builder import JoinType
|
||||||
from frappe.utils.safe_exec import get_safe_globals
|
from frappe.utils.safe_exec import get_safe_globals
|
||||||
|
from frappe.utils import now_datetime
|
||||||
|
from pypika import Criterion
|
||||||
|
|
||||||
DOCTYPE = "CRM Service Level Agreement"
|
DOCTYPE = "CRM Service Level Agreement"
|
||||||
|
|
||||||
@ -15,12 +17,15 @@ def get_sla(doc: Document) -> Document:
|
|||||||
check_permissions(DOCTYPE, None)
|
check_permissions(DOCTYPE, None)
|
||||||
SLA = frappe.qb.DocType(DOCTYPE)
|
SLA = frappe.qb.DocType(DOCTYPE)
|
||||||
Priority = frappe.qb.DocType("CRM Service Level Priority")
|
Priority = frappe.qb.DocType("CRM Service Level Priority")
|
||||||
|
now = now_datetime()
|
||||||
priority = doc.communication_status
|
priority = doc.communication_status
|
||||||
q = (
|
q = (
|
||||||
frappe.qb.from_(SLA)
|
frappe.qb.from_(SLA)
|
||||||
.select(SLA.name, SLA.condition)
|
.select(SLA.name, SLA.condition)
|
||||||
.where(SLA.apply_on == doc.doctype)
|
.where(SLA.apply_on == doc.doctype)
|
||||||
.where(SLA.enabled == True)
|
.where(SLA.enabled == True)
|
||||||
|
.where(Criterion.any([SLA.start_date.isnull(), SLA.start_date <= now]))
|
||||||
|
.where(Criterion.any([SLA.end_date.isnull(), SLA.end_date >= now]))
|
||||||
)
|
)
|
||||||
if priority:
|
if priority:
|
||||||
q = (
|
q = (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user