[fix] check job application unique email id

This commit is contained in:
Anand Doshi 2015-03-30 21:10:49 +05:30
parent 4ec1a9e8f6
commit d6a360b51b
2 changed files with 14 additions and 2 deletions

View File

@ -64,7 +64,7 @@ class Lead(SellingController):
self.email_id)
if len(email_list) > 1:
items = [e[0] for e in email_list if e[0]!=self.name]
frappe.throw(_("Email id must be unique, already exists for {0}").format(comma_and(items)))
frappe.throw(_("Email id must be unique, already exists for {0}").format(comma_and(items)), frappe.DuplicateEntryError)
def on_trash(self):
frappe.db.sql("""update `tabIssue` set lead='' where lead=%s""",
@ -124,7 +124,7 @@ def make_opportunity(source_name, target_doc=None):
}}, target_doc)
return target_doc
@frappe.whitelist()
def make_quotation(source_name, target_doc=None):
target_doc = get_mapped_doc("Lead", source_name,

View File

@ -7,6 +7,7 @@ from __future__ import unicode_literals
from frappe.model.document import Document
import frappe
from frappe import _
from frappe.utils import comma_and
class JobApplicant(Document):
def autoname(self):
@ -15,5 +16,16 @@ class JobApplicant(Document):
frappe.throw(_("Name or Email is mandatory"), frappe.NameError)
self.name = " - ".join(keys)
def validate(self):
self.check_email_id_is_unique()
def check_email_id_is_unique(self):
if self.email_id:
names = frappe.db.sql_list("""select name from `tabJob Application`
where email_id=%s and name!=%s""", (self.email_id, self.name))
if names:
frappe.throw(_("Email id must be unique, already exists for {0}").format(comma_and(names)), frappe.DuplicateEntryError)
def set_sender(self, sender):
self.email_id = sender