Skip to content

Commit

Permalink
refactor: use frappe.delete_doc instead of frappe.db.delete
Browse files Browse the repository at this point in the history
  • Loading branch information
krantheman committed Jun 17, 2024
1 parent 6b60596 commit e6f9bba
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hrms/api/roster.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def create_shift_assignment_schedule(

@frappe.whitelist()
def delete_shift_assignment_schedule(schedule: str) -> None:
frappe.db.delete("Shift Assignment", {"schedule": schedule})
for shift_assignment in frappe.get_all("Shift Assignment", {"schedule": schedule}, pluck="name"):
doc = frappe.get_doc("Shift Assignment", shift_assignment)
if doc.docstatus == 1:
doc.cancel()
frappe.delete_doc("Shift Assignment", shift_assignment)
frappe.delete_doc("Shift Assignment Schedule", schedule)


Expand Down

0 comments on commit e6f9bba

Please sign in to comment.