fix: change get all to sql list
This commit is contained in:
parent
cbc22e6369
commit
f6cf58fa8c
@ -20,14 +20,16 @@ class LeaveLedgerEntry(Document):
|
||||
|
||||
def validate_leave_allocation_against_leave_application(ledger):
|
||||
''' Checks that leave allocation has no leave application against it '''
|
||||
leave_application_records = frappe.get_all("Leave Ledger Entry",
|
||||
filters={
|
||||
'employee': ledger.employee,
|
||||
'leave_type': ledger.leave_type,
|
||||
'transaction_type': 'Leave Application',
|
||||
'from_date': (">=", ledger.from_date),
|
||||
'to_date': ('<=', ledger.to_date)
|
||||
}, fields=['transaction_name'])
|
||||
leave_application_records = frappe.db.sql_list("""
|
||||
SELECT transaction_name
|
||||
FROM `tabLeave Application`
|
||||
WHERE
|
||||
employee=%s,
|
||||
leave_type=%s,
|
||||
transaction_type='Leave Application',
|
||||
from_date>=%s,
|
||||
to_date<=%s
|
||||
""", (ledger.employee, ledger.leave_type, ledger.from_date, ledger.to_date))
|
||||
|
||||
if leave_application_records:
|
||||
frappe.throw(_("Leave allocation %s is linked with leave application %s"
|
||||
|
@ -12,6 +12,6 @@ from frappe.model.document import Document
|
||||
class LeaveType(Document):
|
||||
def validate(self):
|
||||
if self.is_lwp:
|
||||
leave_allocation = frappe.get_doc("Leave Allocation", {"leave_type": self.name}, ['name'])
|
||||
leave_allocation = frappe.db.sql_list("""select name from `tabLeave Allocation` where leave_type=%s""", (self.name))
|
||||
if leave_allocation:
|
||||
frappe.throw(_("""Leave application is linked with leave allocations {0}. Leave application cannot be set as leave without pay""").format(", ".join(leave_allocation))) #nosec
|
Loading…
x
Reference in New Issue
Block a user