From 3d55e3dd59d7002564c66d71c06ef0b19f97d660 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 22 Jan 2013 12:09:51 +0530 Subject: [PATCH] fmt_money - don't format flat types --- selling/doctype/lead/lead.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/selling/doctype/lead/lead.py b/selling/doctype/lead/lead.py index dd24ff696c..1b7311166b 100644 --- a/selling/doctype/lead/lead.py +++ b/selling/doctype/lead/lead.py @@ -16,7 +16,7 @@ from __future__ import unicode_literals import webnotes - +from webnotes import _ from webnotes.utils import cstr, validate_email_add from webnotes.model.doc import Document, addchild from webnotes import session, msgprint @@ -51,10 +51,23 @@ class DocType(TransactionBase): if not validate_email_add(self.doc.email_id): msgprint('Please enter valid email id.') raise Exception + def on_update(self): if self.doc.contact_date: self.add_calendar_event() + + self.check_email_id_is_unique() + + def check_email_id_is_unique(self): + if self.doc.email_id: + # validate email is unique + email_list = webnotes.conn.sql("""select name from tabLead where email_id=%s""", + self.doc.email_id) + if len(email_list) > 1: + items = [e[0] for e in email_list if e[0]!=self.doc.name] + webnotes.msgprint(_("""Email Id must be unique, already exists for: """) + \ + ", ".join(items), raise_exception=True) def add_calendar_event(self): # delete any earlier event by this lead