fix: when checking for duplicates, ignore same document

This commit is contained in:
Jannat Patel
2025-02-12 13:09:22 +05:30
parent ee73790127
commit f63d57c4a9

View File

@@ -19,7 +19,8 @@ class LMSBatchEnrollment(Document):
def validate_duplicate_members(self): def validate_duplicate_members(self):
if frappe.db.exists( if frappe.db.exists(
"LMS Batch Enrollment", {"batch": self.batch, "member": self.member} "LMS Batch Enrollment",
{"batch": self.batch, "member": self.member, "name": ["!=", self.name]},
): ):
frappe.throw(_("Member already enrolled in this batch")) frappe.throw(_("Member already enrolled in this batch"))
@@ -70,7 +71,7 @@ def send_confirmation_email(doc):
if not doc.confirmation_email_sent and ( if not doc.confirmation_email_sent and (
outgoing_email_account or frappe.conf.get("mail_login") outgoing_email_account or frappe.conf.get("mail_login")
): ):
doc.send_mail() send_mail(doc)
doc.db_set("confirmation_email_sent", 1) doc.db_set("confirmation_email_sent", 1)